[Groonga-commit] groonga/grnxx at 6f791a2 [master] Add modulus (%) to Int. (#88)

Back to archive index

susumu.yata null+****@clear*****
Fri Oct 24 11:00:51 JST 2014


susumu.yata	2014-10-24 11:00:51 +0900 (Fri, 24 Oct 2014)

  New Revision: 6f791a25372e5bee02553f54a008e15ae2361e5f
  https://github.com/groonga/grnxx/commit/6f791a25372e5bee02553f54a008e15ae2361e5f

  Message:
    Add modulus (%) to Int. (#88)

  Modified files:
    include/grnxx/new_types/int.hpp

  Modified: include/grnxx/new_types/int.hpp (+11 -0)
===================================================================
--- include/grnxx/new_types/int.hpp    2014-10-24 10:59:47 +0900 (eed8030)
+++ include/grnxx/new_types/int.hpp    2014-10-24 11:00:51 +0900 (9c0b126)
@@ -156,6 +156,10 @@ class Int {
     return (is_na() || rhs.is_na() || (rhs.value_ == 0)) ?
            na() : Int(value_ / rhs.value_);
   }
+  Int operator%(Int rhs) const {
+    return (is_na() || rhs.is_na() || (rhs.value_ == 0)) ?
+           na() : Int(value_ % rhs.value_);
+  }
 
   Int &operator+=(Int rhs) & {
     return *this = operator+(rhs);
@@ -173,6 +177,13 @@ class Int {
     }
     return *this;
   }
+  Int &operator%=(Int rhs) &{
+    if (!is_na()) {
+      value_ = (rhs.is_na() || (rhs.value_ == 0)) ?
+               na_value() : (value_ % rhs.value_);
+    }
+    return *this;
+  }
 
   // -- Comparison operators --
 
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index