Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65576 - sandbox/opaque/boost/opaque
From: vicente.botet_at_[hidden]
Date: 2010-09-24 13:26:12


Author: viboes
Date: 2010-09-24 13:26:10 EDT (Fri, 24 Sep 2010)
New Revision: 65576
URL: http://svn.boost.org/trac/boost/changeset/65576

Log:
Opaque: Simplify proto for operators classes
Text files modified:
   sandbox/opaque/boost/opaque/new_type.hpp | 7 +++++
   sandbox/opaque/boost/opaque/opaque_type.hpp | 15 ++++++-------
   sandbox/opaque/boost/opaque/operators.hpp | 42 ++++++++++++++++++++++++++++++++-------
   3 files changed, 47 insertions(+), 17 deletions(-)

Modified: sandbox/opaque/boost/opaque/new_type.hpp
==============================================================================
--- sandbox/opaque/boost/opaque/new_type.hpp (original)
+++ sandbox/opaque/boost/opaque/new_type.hpp 2010-09-24 13:26:10 EDT (Fri, 24 Sep 2010)
@@ -52,7 +52,7 @@
         template <typename W>
         explicit new_type(W v) : val_(v) {}
         new_type(){}
- //~ new_type(const new_type & rhs) : val_(rhs.val_) {}
+ new_type(const new_type & rhs) : val_(rhs.val_) {}
         explicit new_type(T v) : val_(v) {}
     protected:
         T val_;
@@ -70,6 +70,11 @@
 
     };
 
+ template <typename T, typename Final, typename UT, typename Base >
+ T new_type_static_cast(new_type<Final, UT, Base> const& v)
+ {
+ return static_cast<T>(v.underlying());
+ }
 
 }
 

Modified: sandbox/opaque/boost/opaque/opaque_type.hpp
==============================================================================
--- sandbox/opaque/boost/opaque/opaque_type.hpp (original)
+++ sandbox/opaque/boost/opaque/opaque_type.hpp 2010-09-24 13:26:10 EDT (Fri, 24 Sep 2010)
@@ -15,7 +15,6 @@
 
 #include <boost/opaque/new_type.hpp>
 #include <boost/opaque/operators.hpp>
-#include <boost/operators.hpp>
 
 namespace boost {
 
@@ -26,13 +25,13 @@
             , boost::integer_arithmetic< Final
               , boost::bitwise< Final
                 , boost::unit_steppable< Final
- , opaque::less_than_comparable<Final, T
- , opaque::equality_comparable<Final, T
- , opaque::addable<Final, T
- , opaque::subtractable<Final, T
- , opaque::multipliable<Final, T
- , opaque::dividable<Final, T
- , opaque::modable<Final, T
+ , opaque::less_than_comparable<Final
+ , opaque::ope::eq<Final
+ , opaque::addable<Final
+ , opaque::subtractable<Final
+ , opaque::multipliable<Final
+ , opaque::dividable<Final
+ , opaque::modable<Final
                                 , underlying_access< Final, T, Base >
>
>

Modified: sandbox/opaque/boost/opaque/operators.hpp
==============================================================================
--- sandbox/opaque/boost/opaque/operators.hpp (original)
+++ sandbox/opaque/boost/opaque/operators.hpp 2010-09-24 13:26:10 EDT (Fri, 24 Sep 2010)
@@ -13,24 +13,50 @@
 #ifndef BOOST_OPAQUE_OPERATORS_HPP
 #define BOOST_OPAQUE_OPERATORS_HPP
 
+#include <boost/opaque/new_type.hpp>
+#include <boost/operators.hpp>
+
 namespace boost {
 
 namespace opaque {
- template <typename Final, typename UT, typename Base>
+ template <typename Base=base_new_type>
+ struct non_copyable : Base {
+ private: // emphasize the following members are private
+ non_copyable( const non_copyable& );
+ };
+
+ template <typename Base=base_new_type>
+ struct non_assignable : Base {
+ private: // emphasize the following members are private
+ non_assignable& operator=(non_assignable const&);
+ };
+
+ template <typename UT, typename Base=base_new_type>
+ struct convertible : Base {
+ operator UT() const{
+ return this->underlying();
+ }
+ };
+
+ template <typename Final, typename Base=base_new_type>
     struct less_than_comparable : Base {
         friend bool operator<(const Final& x, const Final& y) {
             return x.underlying() < y.underlying();
         }
     };
 
- template <typename Final, typename UT, typename Base>
- struct equality_comparable : Base {
+ namespace ope {
+ template <typename Final, typename Base=base_new_type>
+ struct eq : Base {
         friend bool operator==(const Final& x, const Final& y) {
             return x.underlying() == y.underlying();
         }
     };
+ }
+ template <typename Final, typename Base=base_new_type>
+ struct equality_comparable1 : boost::equality_comparable1<Final, ope::eq<Final, Base> > {};
 
- template <typename Final, typename UT, typename Base>
+ template <typename Final, typename Base=base_new_type>
     struct addable : Base {
         friend Final& operator+=(Final& x, const Final& y) {
             x.underlying() += y.underlying();
@@ -38,7 +64,7 @@
         }
     };
 
- template <typename Final, typename UT, typename Base>
+ template <typename Final, typename Base=base_new_type>
     struct subtractable : Base {
         friend Final& operator-=(Final& x, const Final& y) {
             x.underlying() -= y.underlying();
@@ -46,7 +72,7 @@
         }
     };
 
- template <typename Final, typename UT, typename Base>
+ template <typename Final, typename Base=base_new_type>
     struct multipliable : Base {
         friend Final& operator*=(Final& x, const Final& y) {
             x.underlying() *= y.underlying();
@@ -54,7 +80,7 @@
         }
     };
 
- template <typename Final, typename UT, typename Base>
+ template <typename Final, typename Base=base_new_type>
     struct dividable : Base {
         friend Final& operator/=(Final& x, const Final& y) {
             x.underlying() /= y.underlying();
@@ -62,7 +88,7 @@
         }
     };
 
- template <typename Final, typename UT, typename Base>
+ template <typename Final, typename Base=base_new_type>
     struct modable : Base {
         friend Final& operator%=(Final& x, const Final& y) {
             x.underlying() %= y.underlying();


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