Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65654 - sandbox/opaque/boost/opaque
From: vicente.botet_at_[hidden]
Date: 2010-09-28 18:22:55


Author: viboes
Date: 2010-09-28 18:22:53 EDT (Tue, 28 Sep 2010)
New Revision: 65654
URL: http://svn.boost.org/trac/boost/changeset/65654

Log:
Opaque:
* Continue defining macros so inheritance is avoided.
* Fix static final function
Text files modified:
   sandbox/opaque/boost/opaque/new_class.hpp | 2
   sandbox/opaque/boost/opaque/operators.hpp | 313 +++++++++++++++++++++++++++++++--------
   2 files changed, 249 insertions(+), 66 deletions(-)

Modified: sandbox/opaque/boost/opaque/new_class.hpp
==============================================================================
--- sandbox/opaque/boost/opaque/new_class.hpp (original)
+++ sandbox/opaque/boost/opaque/new_class.hpp 2010-09-28 18:22:53 EDT (Tue, 28 Sep 2010)
@@ -79,7 +79,7 @@
             return static_cast<Final const&>(*f);
         }
         template<typename F>
- Final& final(F* f) {
+ static Final& final(F* f) {
             return static_cast<Final&>(*f);
         }
 

Modified: sandbox/opaque/boost/opaque/operators.hpp
==============================================================================
--- sandbox/opaque/boost/opaque/operators.hpp (original)
+++ sandbox/opaque/boost/opaque/operators.hpp 2010-09-28 18:22:53 EDT (Tue, 28 Sep 2010)
@@ -20,60 +20,124 @@
 
 namespace opaque {
 namespace ope {
- template <typename Base>
- struct copy_delete : Base {
- private: // emphasize the following members are private
- copy_delete( const copy_delete & );
- };
-
- template <typename Base>
- struct assign_delete : Base {
- private: // emphasize the following members are private
- assign_delete& operator=(assign_delete const&);
- };
-
- template <typename UT, typename Base>
- struct conversion : Base {
- operator UT() const{
- return this->underlying();
- }
+
+#define BOOST_OPAQUE_HIDING_COPY(T) \
+ private: \
+ T( const T& );
+
+ struct hiding_copy {
+ template <typename Final, typename UT, typename Base>
+ struct type : Base {
+ BOOST_OPAQUE_HIDING_COPY(type)
+ };
+ };
+
+#define BOOST_OPAQUE_HIDING_ASSIGN(T) \
+ private: \
+ T& operator=(T const&);
+
+ struct hiding_assign {
+ template <typename Final, typename UT, typename Base>
+ struct type : Base {
+ BOOST_OPAQUE_HIDING_ASSIGN(type)
+ };
+ };
+
+#define BOOST_OPAQUE_USING_CONVERSION(Final,UT) \
+ public: \
+ operator UT() const{ \
+ return Final::underlying(this); \
+ }
+
+ struct using_conversion {
+ template <typename Final, typename UT, typename Base>
+ struct type: Base {
+ BOOST_OPAQUE_USING_CONVERSION(Final,UT)
+ };
     };
 
 #define BOOST_OPAQUE_USING_LESS_THAN(Final) \
         public :\
         bool operator<(const Final& rhs) const { \
- return Final::final(this).underlying() < rhs.underlying();\
+ return Final::underlying(this) < rhs.underlying();\
         }
 
+ template <typename Final, typename Base>
+ struct less_than : Base {
+ BOOST_OPAQUE_USING_LESS_THAN(Final)
+ };
+
+ struct using_less_than {
+ template <typename Final, typename UT, typename Base>
+ struct type: Base {
+ BOOST_OPAQUE_USING_LESS_THAN(Final)
+ };
+ };
+
 #define BOOST_OPAQUE_USING_LESS_THAN_EQUAL(Final) \
         public :\
         bool operator<=(const Final& rhs) const { \
- return Final::final(this).underlying() <= rhs.underlying();\
+ return Final::underlying(this) <= rhs.underlying();\
         }
 
+ struct using_less_than_equal {
+ template <typename Final, typename UT, typename Base>
+ struct type: Base {
+ BOOST_OPAQUE_USING_LESS_THAN_EQUAL(Final)
+ };
+ };
+
 #define BOOST_OPAQUE_USING_GREATER_THAN(Final) \
         public :\
         bool operator>(const Final& rhs) const { \
- return Final::final(this).underlying() > rhs.underlying();\
+ return Final::underlying(this) > rhs.underlying();\
         }
 
+ struct using_greater_than {
+ template <typename Final, typename UT, typename Base>
+ struct type: Base {
+ BOOST_OPAQUE_USING_GREATER_THAN(Final)
+ };
+ };
+
 #define BOOST_OPAQUE_USING_GREATER_THAN_EQUAL(Final) \
         public :\
         bool operator>=(const Final& rhs) const { \
- return Final::final(this).underlying() >= rhs.underlying();\
+ return Final::underlying(this) >= rhs.underlying();\
         }
 
- template <typename Final, typename Base>
- struct less_than : Base {
- BOOST_OPAQUE_USING_LESS_THAN(Final)
+ struct using_greater_than_equal {
+ template <typename Final, typename UT, typename Base>
+ struct type: Base {
+ BOOST_OPAQUE_USING_GREATER_THAN_EQUAL(Final)
+ };
     };
 
+#define BOOST_OPAQUE_USING_EQUAL(Final) \
+ public :\
+ bool operator==(const Final& rhs) const { \
+ return Final::underlying(this) == rhs.underlying();\
+ }
+
     template <typename Final, typename Base>
     struct equal : Base {
         friend bool operator==(const Final& x, const Final& y) {
             return x.underlying() == y.underlying();
         }
     };
+ struct using_equal {
+ template <typename Final, typename UT, typename Base>
+ struct type: Base {
+ BOOST_OPAQUE_USING_EQUAL(Final)
+ };
+ };
+
+#define BOOST_OPAQUE_USING_NOT_EQUAL(Final) \
+ public :\
+ bool operator!=(const Final& rhs) const { \
+ return Final::underlying(this) != rhs.underlying();\
+ }
+
 
     template <typename Final, typename Base>
     struct not_equal : Base {
@@ -81,91 +145,210 @@
             return x.underlying() != y.underlying();
         }
     };
+ struct using_not_equal {
+ template <typename Final, typename UT, typename Base>
+ struct type: Base {
+ BOOST_OPAQUE_USING_NOT_EQUAL(Final)
+ };
+ };
+
+#define BOOST_OPAQUE_USING_PLUS_ASSIGN(Final) \
+ public :\
+ Final& operator+=(const Final& rhs) { \
+ Final::underlying(this) += rhs.underlying();\
+ return Final::final(this); \
+ }
 
     template <typename Final, typename Base>
     struct plus_assign : Base {
- friend Final& operator+=(Final& x, const Final& y) {
- x.underlying() += y.underlying();
- return x;
- }
+ BOOST_OPAQUE_USING_PLUS_ASSIGN(Final)
+ };
+ struct using_plus_assign {
+ template <typename Final, typename UT, typename Base>
+ struct type: Base {
+ BOOST_OPAQUE_USING_PLUS_ASSIGN(Final)
+ };
     };
 
+#define BOOST_OPAQUE_USING_MINUS_ASSIGN(Final) \
+ public :\
+ Final& operator-=(const Final& rhs) { \
+ Final::underlying(this) -= rhs.underlying();\
+ return Final::final(this); \
+ }
+
     template <typename Final, typename Base>
     struct minus_assign : Base {
- friend Final& operator-=(Final& x, const Final& y) {
- x.underlying() -= y.underlying();
- return x;
- }
+ BOOST_OPAQUE_USING_MINUS_ASSIGN(Final)
+ };
+ struct using_minus_assign {
+ template <typename Final, typename UT, typename Base>
+ struct type: Base {
+ BOOST_OPAQUE_USING_MINUS_ASSIGN(Final)
+ };
     };
 
+#define BOOST_OPAQUE_USING_MULTIPLY_ASSIGN(Final) \
+ public :\
+ Final& operator*=(const Final& rhs) { \
+ Final::underlying(this) *= rhs.underlying();\
+ return Final::final(this); \
+ }
+
     template <typename Final, typename Base>
     struct multiply_assign : Base {
- friend Final& operator*=(Final& x, const Final& y) {
- x.underlying() *= y.underlying();
- return x;
- }
+ BOOST_OPAQUE_USING_MULTIPLY_ASSIGN(Final)
+ };
+ struct using_multiply_assign {
+ template <typename Final, typename UT, typename Base>
+ struct type: Base {
+ BOOST_OPAQUE_USING_MULTIPLY_ASSIGN(Final)
+ };
     };
 
+#define BOOST_OPAQUE_USING_DIVIDE_ASSIGN(Final) \
+ public :\
+ Final& operator/=(const Final& rhs) { \
+ Final::underlying(this) /= rhs.underlying();\
+ return Final::final(this); \
+ }
+
     template <typename Final, typename Base>
     struct divide_assign : Base {
- friend Final& operator/=(Final& x, const Final& y) {
- x.underlying() /= y.underlying();
- return x;
- }
+ BOOST_OPAQUE_USING_DIVIDE_ASSIGN(Final)
+ };
+ struct using_divide_assign {
+ template <typename Final, typename UT, typename Base>
+ struct type: Base {
+ BOOST_OPAQUE_USING_DIVIDE_ASSIGN(Final)
+ };
     };
 
+#define BOOST_OPAQUE_USING_MODULUS_ASSIGN(Final) \
+ public :\
+ Final& operator%=(const Final& rhs) { \
+ Final::underlying(this) %= rhs.underlying();\
+ return Final::final(this); \
+ }
+
     template <typename Final, typename Base>
     struct modulus_assign : Base {
- friend Final& operator%=(Final& x, const Final& y) {
- x.underlying() %= y.underlying();
- return x;
- }
+ BOOST_OPAQUE_USING_MODULUS_ASSIGN(Final)
     };
+ struct using_modulus_assign {
+ template <typename Final, typename UT, typename Base>
+ struct type: Base {
+ BOOST_OPAQUE_USING_MODULUS_ASSIGN(Final)
+ };
+ };
+
+#define BOOST_OPAQUE_USING_BITWISE_XOR_ASSIGN(Final) \
+ public :\
+ Final& operator^=(const Final& rhs) { \
+ Final::underlying(this) ^= rhs.underlying();\
+ return Final::final(this); \
+ }
 
     template <typename Final, typename Base>
     struct bitwise_xor_assign : Base {
- friend Final& operator^=(Final& x, const Final& y) {
- x.underlying() ^= y.underlying();
- return x;
- }
+ BOOST_OPAQUE_USING_BITWISE_XOR_ASSIGN(Final)
+ };
+ struct using_bitwise_xor_assign {
+ template <typename Final, typename UT, typename Base>
+ struct type: Base {
+ BOOST_OPAQUE_USING_BITWISE_XOR_ASSIGN(Final)
+ };
     };
 
+#define BOOST_OPAQUE_USING_BITWISE_AND_ASSIGN(Final) \
+ public :\
+ Final& operator&=(const Final& rhs) { \
+ Final::underlying(this) &= rhs.underlying();\
+ return Final::final(this); \
+ }
+
+ struct using_bitwise_and_assign {
+ template <typename Final, typename UT, typename Base>
+ struct type: Base {
+ BOOST_OPAQUE_USING_BITWISE_AND_ASSIGN(Final)
+ };
+ };
     template <typename Final, typename Base>
     struct bitwise_and_assign : Base {
- friend Final& operator&=(Final& x, const Final& y) {
- x.underlying() &= y.underlying();
- return x;
- }
+ BOOST_OPAQUE_USING_BITWISE_AND_ASSIGN(Final)
     };
 
+#define BOOST_OPAQUE_USING_BITWISE_OR_ASSIGN(Final) \
+ public :\
+ Final& operator|=(const Final& rhs) { \
+ Final::underlying(this) |= rhs.underlying();\
+ return Final::final(this); \
+ }
+
+ struct using_bitwise_or_assign {
+ template <typename Final, typename UT, typename Base>
+ struct type: Base {
+ BOOST_OPAQUE_USING_BITWISE_OR_ASSIGN(Final)
+ };
+ };
     template <typename Final, typename Base>
     struct bitwise_or_assign : Base {
- friend Final& operator|=(Final& x, const Final& y) {
- x.underlying() |= y.underlying();
- return x;
+ BOOST_OPAQUE_USING_BITWISE_OR_ASSIGN(Final)
+ };
+
+#define BOOST_OPAQUE_USING_LEFT_SHIFT_ASSIGN(Final) \
+ public :\
+ Final& operator<<=(const Final& rhs) { \
+ Final::underlying(this) <<= rhs.underlying();\
+ return Final::final(this); \
         }
+
+ struct using_left_shift_assign {
+ template <typename Final, typename UT, typename Base>
+ struct type: Base {
+ BOOST_OPAQUE_USING_LEFT_SHIFT_ASSIGN(Final)
+ };
     };
     template <typename Final, typename Base>
     struct left_shift_assign : Base {
- friend Final& operator<<=(Final& x, const Final& y) {
- x.underlying() <<= y.underlying();
- return x;
+ BOOST_OPAQUE_USING_LEFT_SHIFT_ASSIGN(Final)
+ };
+
+#define BOOST_OPAQUE_USING_RIGHT_SHIFT_ASSIGN(Final) \
+ public :\
+ Final& operator>>=(const Final& rhs) { \
+ Final::underlying(this) >>= rhs.underlying();\
+ return Final::final(this); \
         }
+
+ struct using_left_right_assign {
+ template <typename Final, typename UT, typename Base>
+ struct type: Base {
+ BOOST_OPAQUE_USING_RIGHT_SHIFT_ASSIGN(Final)
+ };
     };
     template <typename Final, typename Base>
     struct right_shift_assign : Base {
- friend Final& operator>>=(Final& x, const Final& y) {
- x.underlying() >>= y.underlying();
- return x;
- }
+ BOOST_OPAQUE_USING_RIGHT_SHIFT_ASSIGN(Final)
     };
     // Unary operators
 
+#define BOOST_OPAQUE_USING_LOGICAL_NOT(Final) \
+ public :\
+ bool operator!() const { \
+ return !Final::underlying(this);\
+ }
+
+ struct using_logical_not {
+ template <typename Final, typename UT, typename Base>
+ struct type: Base {
+ BOOST_OPAQUE_USING_LOGICAL_NOT(Final)
+ };
+ };
+
     template <typename Final, typename Base>
     struct logical_not : Base {
- friend bool operator!(Final const& x) {
- return !(x.underlying());
- }
+ BOOST_OPAQUE_USING_LOGICAL_NOT(Final)
     };
 
     template <typename Final, typename Base>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk