Browse Source

Extended Integer class

- added operator overloading for && and || for
receiving a boolean parameter
Patrick 4 năm trước cách đây
mục cha
commit
2d2ad499d3
2 tập tin đã thay đổi với 12 bổ sung0 xóa
  1. 10 0
      source/boxing/Integer.cpp
  2. 2 0
      source/boxing/Integer.hpp

+ 10 - 0
source/boxing/Integer.cpp

@@ -207,6 +207,11 @@ bool ls_std::Integer::operator&&(int _value) const
   return this->value && _value;
 }
 
+bool ls_std::Integer::operator&&(bool expression) const
+{
+  return this->value && expression;
+}
+
 bool ls_std::Integer::operator||(const Integer &_integer) const
 {
   return this->value || _integer;
@@ -217,6 +222,11 @@ bool ls_std::Integer::operator||(int _value) const
   return this->value || _value;
 }
 
+bool ls_std::Integer::operator||(bool expression) const
+{
+  return this->value || expression;
+}
+
 void ls_std::Integer::operator++()
 {
   this->value += 1;

+ 2 - 0
source/boxing/Integer.hpp

@@ -87,8 +87,10 @@ namespace ls_std {
 
       bool operator&&(const Integer& _integer) const;
       bool operator&&(int _value) const;
+      bool operator&&(bool expression) const;
       bool operator||(const Integer& _integer) const;
       bool operator||(int _value) const;
+      bool operator||(bool expression) const;
 
       // increment / decrement operator