OSDN Git Service

operator/bit: lshift.hpp, rshift.hpp Add.
authormyun2 <myun2@nwhite.info>
Wed, 6 Jun 2012 17:33:27 +0000 (02:33 +0900)
committermyun2 <myun2@nwhite.info>
Wed, 6 Jun 2012 17:33:27 +0000 (02:33 +0900)
roast/include/roast/adapter/operator/bit/lshift.hpp [new file with mode: 0644]
roast/include/roast/adapter/operator/bit/rshift.hpp [new file with mode: 0644]

diff --git a/roast/include/roast/adapter/operator/bit/lshift.hpp b/roast/include/roast/adapter/operator/bit/lshift.hpp
new file mode 100644 (file)
index 0000000..3fb7467
--- /dev/null
@@ -0,0 +1,54 @@
+//     Roast+ License
+
+/*
+*/
+#ifndef __SFJP_ROAST__adapter__operator__bit__lshift_HPP__
+#define __SFJP_ROAST__adapter__operator__bit__lshift_HPP__
+
+namespace roast
+{
+       namespace adapter
+       {
+               /////////////////////////////////////////////////////////////////////////
+               
+               template <typename _Facade, typename _ValueType>
+               class lshift_adapter
+               {
+               protected:
+                       virtual void lshift(const _ValueType& lshift_value)=0;
+                       
+               public:
+                       _Facade operator <<(const _ValueType& lshift_value) const {
+                               _Facade work = *( static_cast<const _Facade*>(this) );  //      *(_Facade*)this;
+                               work <<= lshift_value;
+                               return work;
+                       }
+                       
+                       _Facade& operator <<=(const _ValueType& lshift_value){
+                               lshift(lshift_value);
+                               return *( static_cast<_Facade*>(this) );        //      *(_Facade*)this;
+                       }
+               };
+               
+               /////////////////////////////////////////////////////////////////////////
+               
+               template <typename _Facade, typename _ValueType>
+               class value_lshift_adapter : public lshift_adapter<_Facade, _ValueType>
+               {
+               private:
+                       _ValueType& m_value;
+               protected:
+                       void lshift(const _ValueType& lshift_value){
+                               m_value <<= lshift_value;
+                       }
+               public:
+                       value_lshift_adapter(_ValueType& value_ref) : m_value(value_ref) {}
+               };
+               
+               /////////////////////////////////////////////////////////////////////////
+       }
+       
+       using namespace adapter;
+}
+
+#endif//__SFJP_ROAST__adapter__operator__bit__lshift_HPP__
diff --git a/roast/include/roast/adapter/operator/bit/rshift.hpp b/roast/include/roast/adapter/operator/bit/rshift.hpp
new file mode 100644 (file)
index 0000000..9ea831c
--- /dev/null
@@ -0,0 +1,54 @@
+//     Roast+ License
+
+/*
+*/
+#ifndef __SFJP_ROAST__adapter__operator__bit__rshift_HPP__
+#define __SFJP_ROAST__adapter__operator__bit__rshift_HPP__
+
+namespace roast
+{
+       namespace adapter
+       {
+               /////////////////////////////////////////////////////////////////////////
+               
+               template <typename _Facade, typename _ValueType>
+               class rshift_adapter
+               {
+               protected:
+                       virtual void rshift(const _ValueType& rshift_value)=0;
+                       
+               public:
+                       _Facade operator >>(const _ValueType& rshift_value) const {
+                               _Facade work = *( static_cast<const _Facade*>(this) );  //      *(_Facade*)this;
+                               work >>= rshift_value;
+                               return work;
+                       }
+                       
+                       _Facade& operator >>=(const _ValueType& rshift_value){
+                               rshift(rshift_value);
+                               return *( static_cast<_Facade*>(this) );        //      *(_Facade*)this;
+                       }
+               };
+               
+               /////////////////////////////////////////////////////////////////////////
+               
+               template <typename _Facade, typename _ValueType>
+               class value_rshift_adapter : public rshift_adapter<_Facade, _ValueType>
+               {
+               private:
+                       _ValueType& m_value;
+               protected:
+                       void rshift(const _ValueType& rshift_value){
+                               m_value >>= rshift_value;
+                       }
+               public:
+                       value_rshift_adapter(_ValueType& value_ref) : m_value(value_ref) {}
+               };
+               
+               /////////////////////////////////////////////////////////////////////////
+       }
+       
+       using namespace adapter;
+}
+
+#endif//__SFJP_ROAST__adapter__operator__bit__rshift_HPP__