OSDN Git Service

inc_decl.hpp: inclemental, inclemental_value への分離
authormyun2 <myun2@nwhite.info>
Tue, 5 Jun 2012 05:11:00 +0000 (14:11 +0900)
committermyun2 <myun2@nwhite.info>
Tue, 5 Jun 2012 05:11:00 +0000 (14:11 +0900)
roast/include/roast/adapter/operator/arith/inc_decl.hpp

index b5872eb..088de2b 100644 (file)
@@ -12,27 +12,41 @@ namespace roast
                namespace op
                {
                        /////////////////////////////////////////////////////////////////////////
-       
-                       template <typename _Facade, typename _TargetType>
+                       
+                       template <typename _Facade>
                        class inclemental
                        {
-                       private:
-                               _ValueType& m_target;
-                       public:
-                               inclemental(_TargetType& target_ref) : m_ref(target_ref) {}
+                       protected:
+                               virtual void increment()=0;
                                
+                       public:
                                //      Prefix Increment (example: ++i)
                                _Facade& operator ++(int){
-                                       m_ref++;
+                                       increment();
                                        return *this;
                                }
                                
                                //      Postfix Increment (example: i++)
                                _Facade operator ++(){
-                                       _Facade old_backup = *this;
-                                       m_ref++;
-                                       return old_backup;
+                                       _Facade old_this = *this;
+                                       increment();
+                                       return old_this;
+                               }
+                       };
+                       
+                       /////////////////////////////////////////////////////////////////////////
+                       
+                       template <typename _Facade, typename _ValueType>
+                       class inclemental_value : inclemental<_Facade>
+                       {
+                       private:
+                               _ValueType& m_value;
+                       protected:
+                               void increment(){
+                                       m_value++;
                                }
+                       public:
+                               inclemental_value(_TargetType& value_ref) : m_value(value_ref) {}
                        };
                        
                        /////////////////////////////////////////////////////////////////////////