Browse Source

[2764] implement postfix version of EncodeNormalizer::operator++.

transform_width in Boost 1.53 requires this version, so build will fail
without it.
JINMEI Tatuya 12 years ago
parent
commit
6c4f943e65
1 changed files with 15 additions and 7 deletions
  1. 15 7
      src/lib/util/encode/base_n.cc

+ 15 - 7
src/lib/util/encode/base_n.cc

@@ -110,15 +110,15 @@ public:
                      const vector<uint8_t>::const_iterator& base_end) :
         base_(base), base_end_(base_end), in_pad_(false)
     {}
-    EncodeNormalizer& operator++() {
-        if (!in_pad_) {
-            ++base_;
-        }
-        if (base_ == base_end_) {
-            in_pad_ = true;
-        }
+    EncodeNormalizer& operator++() { // prefix version
+        increment();
         return (*this);
     }
+    EncodeNormalizer operator++(int) { // postfix version
+        const EncodeNormalizer copy = *this;
+        increment();
+        return (copy);
+    }
     const uint8_t& operator*() const {
         if (in_pad_) {
             return (BINARY_ZERO_CODE);
@@ -130,6 +130,14 @@ public:
         return (base_ == other.base_);
     }
 private:
+    void increment() {
+        if (!in_pad_) {
+            ++base_;
+        }
+        if (base_ == base_end_) {
+            in_pad_ = true;
+        }
+    }
     vector<uint8_t>::const_iterator base_;
     const vector<uint8_t>::const_iterator base_end_;
     bool in_pad_;