Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65614 - sandbox/opaque/boost/opaque
From: vicente.botet_at_[hidden]
Date: 2010-09-26 17:13:04


Author: viboes
Date: 2010-09-26 17:13:03 EDT (Sun, 26 Sep 2010)
New Revision: 65614
URL: http://svn.boost.org/trac/boost/changeset/65614

Log:
Opaque: Refactor and cleanup

Text files modified:
   sandbox/opaque/boost/opaque/combined_operators.hpp | 4 +-
   sandbox/opaque/boost/opaque/new_class.hpp | 26 ++++++++++++-
   sandbox/opaque/boost/opaque/new_type.hpp | 71 ++++-----------------------------------
   sandbox/opaque/boost/opaque/private_opaque_class.hpp | 46 +++++++++++++++++++++---
   sandbox/opaque/boost/opaque/private_opaque_type.hpp | 52 +++-------------------------
   sandbox/opaque/boost/opaque/public_opaque_class.hpp | 51 +++++++++++++++++++++++++--
   sandbox/opaque/boost/opaque/public_opaque_type.hpp | 68 +------------------------------------
   7 files changed, 127 insertions(+), 191 deletions(-)

Modified: sandbox/opaque/boost/opaque/combined_operators.hpp
==============================================================================
--- sandbox/opaque/boost/opaque/combined_operators.hpp (original)
+++ sandbox/opaque/boost/opaque/combined_operators.hpp 2010-09-26 17:13:03 EDT (Sun, 26 Sep 2010)
@@ -222,7 +222,7 @@
> > {};
 
 
-
+
 }
     template <typename T>
     struct inherited_from_undelying {
@@ -234,7 +234,7 @@
                         , opaque::unit_steppable< Final
                             , opaque::ope::unary_plus< Final
                                 , opaque::ope::unary_minus< Final
- , Base
+ , Base
>
>
>

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-26 17:13:03 EDT (Sun, 26 Sep 2010)
@@ -13,14 +13,34 @@
 #ifndef BOOST_OPAQUE_NEW_CLASS_HPP
 #define BOOST_OPAQUE_NEW_CLASS_HPP
 
-#include <boost/opaque/new_type.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/fold.hpp>
 
 namespace boost {
 
+ class base_new_type {};
+
+ ////// implementation //////
+ namespace detail{
+
+ template<typename NT, typename UT, typename State, typename Concept>
+ struct do_inhetit : Concept::template type<NT, UT, State> {
+ };
+
+ template<typename NT, typename UT>
+ struct inherit {
+ template<typename State, typename Concept>
+ struct apply{
+ typedef do_inhetit<NT, UT, State, Concept> type;
+ };
+ };
+
+ }
+
     template <typename Final, typename T, typename Concepts=boost::mpl::vector0<>, typename Base=base_new_type >
- class new_class : public
+ class new_class : public
         //~ Base
- boost::mpl::fold<Concepts, Base, detail::inherit<Final, T> >::type
+ boost::mpl::fold<Concepts, Base, detail::inherit<Final, T> >::type
     {
     public:
         typedef T underlying_type;

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-26 17:13:03 EDT (Sun, 26 Sep 2010)
@@ -13,83 +13,28 @@
 #ifndef BOOST_OPAQUE_NEW_TYPE_HPP
 #define BOOST_OPAQUE_NEW_TYPE_HPP
 
+#include <boost/opaque/new_class.hpp>
 #include <boost/mpl/vector.hpp>
-#include <boost/mpl/fold.hpp>
 
 namespace boost {
 
- class base_new_type {};
 
- ////// implementation //////
- namespace detail{
-
- template<typename NT, typename UT, typename State, typename Concept>
- struct do_inhetit : Concept::template type<NT, UT, State> {
- };
-
- template<typename NT, typename UT>
- struct inherit {
- template<typename State, typename Concept>
- struct apply{
- typedef do_inhetit<NT, UT, State, Concept> type;
- };
- };
-
- }
     template <typename T, typename Tag, typename Concepts=boost::mpl::vector0<>, typename Base=base_new_type>
     class new_type
- : public
- boost::mpl::fold<Concepts, Base, detail::inherit<new_type<T, Tag, Concepts, Base>, T> >::type
+ : public new_class<new_type<T, Tag, Concepts, Base>, T, Concepts, Base>
     {
- typedef typename
- boost::mpl::fold<Concepts, Base, detail::inherit<new_type<T, Tag, Concepts, Base>, T> >::type
- base_type;
-
+ typedef new_class<new_type<T, Tag, Concepts, Base>, T, Concepts, Base> base_type;
     public:
- typedef T underlying_type;
-
         template <typename W>
- explicit new_type(W v) : val_(v) {}
+ explicit new_type(W v) : base_type(v) {}
         new_type(){}
- new_type(const new_type & rhs) : val_(rhs.val_) {}
- explicit new_type(T v) : val_(v) {}
- //~ new_type & operator=(const new_type & rhs) {
- //~ val_ = rhs.val_; return *this;
- //~ }
- protected:
- T val_;
-
- public:
- underlying_type const& underlying() const {
- return val_;
- }
- underlying_type& underlying() {
- return val_;
- }
-
- template<typename F>
- static underlying_type& underlying(F* f){
- return final(f).underlying();
- }
-
- template<typename F>
- static underlying_type const& underlying(F const* f){
- return final(f).underlying();
- }
-
- template<typename F>
- static new_type const& final(F const* f) {
- return static_cast<new_type const&>(*f);
- }
- template<typename F>
- new_type& final(F* f) {
- return static_cast<new_type&>(*f);
- }
+ new_type(const new_type & rhs) : base_type(rhs.val_) {}
+ explicit new_type(T v) : base_type(v) {}
 
     };
 
- template <typename T, typename UT, typename Base, typename Tag >
- T opaque_static_cast(new_type<UT, Base,Tag> const& v)
+ template <typename T, typename UT, typename Tag, typename Concepts, typename Base >
+ T opaque_static_cast(new_type<UT,Tag,Concepts,Base> const& v)
     {
         return static_cast<T>(v.underlying());
     }

Modified: sandbox/opaque/boost/opaque/private_opaque_class.hpp
==============================================================================
--- sandbox/opaque/boost/opaque/private_opaque_class.hpp (original)
+++ sandbox/opaque/boost/opaque/private_opaque_class.hpp 2010-09-26 17:13:03 EDT (Sun, 26 Sep 2010)
@@ -14,7 +14,7 @@
 #define BOOST_OPAQUE_PRIVATE_OPAQUE_CLASS_HPP
 
 #include <boost/opaque/combined_operators.hpp>
-#include <boost/opaque/private_opaque_type.hpp>
+//~ #include <boost/opaque/private_opaque_type.hpp>
 
 #include <boost/type_traits/is_class.hpp>
 #include <boost/type_traits/is_base_of.hpp>
@@ -22,18 +22,50 @@
 
 namespace boost {
 
-
+ class base_private_opaque_type {};
+
+ template <typename Final, typename UT, typename Base=base_new_type>
+ struct transitive_explicit_substituable;
+
+ namespace detail {
+
+ template <typename Final, typename UT, typename Base, bool B>
+ struct transitive_explicit_substituable_next_level;
+
+ template <typename Final, typename UT, typename Base>
+ struct transitive_explicit_substituable_next_level<Final, UT, Base, true>
+ : transitive_explicit_substituable<Final, typename UT::underlying_type, Base> { };
+
+ template <typename Final, typename UT, typename Base>
+ struct transitive_explicit_substituable_next_level<Final, UT, Base, false> : Base { };
+
+ }
+
+ template <typename Final, typename UT, typename Base>
+ struct transitive_explicit_substituable
+#if defined(BOOST_NO_EXPLICIT_CONVERSION_OPERATORS)
+ : Base {};
+#else
+ : detail::transitive_explicit_substituable_next_level<Final, UT, Base,
+ mpl::and_<is_class<UT>, is_base_of<base_private_opaque_type, UT> >::value>
+ {
+ explicit operator UT() const {
+ return Final::final(this).underlying();
+ }
+ };
+#endif
+
     template <typename Final, typename T, typename Concepts=boost::mpl::vector0<>, typename Base=base_private_opaque_type>
- class private_opaque_class : public
+ class private_opaque_class : public
             new_class< Final, T, Concepts,
- transitive_explicit_substituable<Final, T,
+ transitive_explicit_substituable<Final, T,
                     typename inherited_from_undelying<T>::template type<Final, T, Base>
>
>
     {
- typedef
+ typedef
             new_class< Final, T, Concepts,
- transitive_explicit_substituable<Final, T,
+ transitive_explicit_substituable<Final, T,
                     typename inherited_from_undelying<T>::template type<Final, T, Base>
>
>
@@ -43,7 +75,7 @@
     public:
         //~ Can instances of UT be explicitly converted to instances of OT? Yes
         //~ Can instances of UT be implicitly converted to instances of OT? No
- //~ Can instances of OT be explicitly converted to instances of UT? Yes.
+ //~ Can instances of OT be explicitly converted to instances of UT? Yes.
             //~ Waiting for explicit conversion operators,, the explicit conversion must be done through the underlying function
         //~ Can instances of OT be implicitly converted to instances of UT? No
 

Modified: sandbox/opaque/boost/opaque/private_opaque_type.hpp
==============================================================================
--- sandbox/opaque/boost/opaque/private_opaque_type.hpp (original)
+++ sandbox/opaque/boost/opaque/private_opaque_type.hpp 2010-09-26 17:13:03 EDT (Sun, 26 Sep 2010)
@@ -16,6 +16,7 @@
 #include <boost/opaque/combined_operators.hpp>
 #include <boost/opaque/new_type.hpp>
 #include <boost/opaque/new_class.hpp>
+#include <boost/opaque/private_opaque_class.hpp>
 
 #include <boost/type_traits/is_class.hpp>
 #include <boost/type_traits/is_base_of.hpp>
@@ -23,60 +24,19 @@
 
 namespace boost {
 
- class base_private_opaque_type {};
-
- template <typename Final, typename UT, typename Base=base_new_type>
- struct transitive_explicit_substituable;
-
- namespace detail {
-
- template <typename Final, typename UT, typename Base, bool B>
- struct transitive_explicit_substituable_next_level;
-
- template <typename Final, typename UT, typename Base>
- struct transitive_explicit_substituable_next_level<Final, UT, Base, true>
- : transitive_explicit_substituable<Final, typename UT::underlying_type, Base> { };
-
- template <typename Final, typename UT, typename Base>
- struct transitive_explicit_substituable_next_level<Final, UT, Base, false> : Base { };
-
- }
-
- template <typename Final, typename UT, typename Base>
- struct transitive_explicit_substituable
-#if defined(BOOST_NO_EXPLICIT_CONVERSION_OPERATORS)
- : Base {};
-#else
- : detail::transitive_explicit_substituable_next_level<Final, UT, Base,
- mpl::and_<is_class<UT>, is_base_of<base_private_opaque_type, UT> >::value>
- {
- explicit operator UT() const {
- return Final::final(this).underlying();
- }
- };
-#endif
-
     template <typename T, typename Tag=void, typename Concepts=boost::mpl::vector0<>, typename Base=base_private_opaque_type>
- class private_opaque_type : public
- new_class< private_opaque_type<T,Tag,Concepts,Base>, T, Concepts,
- transitive_explicit_substituable<private_opaque_type<T,Tag,Concepts,Base >, T,
- typename inherited_from_undelying<T>::template type<private_opaque_type<T,Tag,Concepts,Base>, T, Base>
- >
- >
+ class private_opaque_type : public
+ private_opaque_class< private_opaque_type<T,Tag,Concepts,Base>, T, Concepts, Base>
     {
- typedef
- new_class< private_opaque_type<T,Tag,Concepts,Base>, T, Concepts,
- transitive_explicit_substituable<private_opaque_type<T,Tag,Concepts,Base>, T,
- typename inherited_from_undelying<T>::template type<private_opaque_type<T,Tag,Concepts,Base>, T, Base>
- >
- >
+ typedef
+ private_opaque_class< private_opaque_type<T,Tag,Concepts,Base>, T, Concepts, Base>
         base_type;
     protected:
         typedef private_opaque_type opaque_type_t;
     public:
         //~ Can instances of UT be explicitly converted to instances of OT? Yes
         //~ Can instances of UT be implicitly converted to instances of OT? No
- //~ Can instances of OT be explicitly converted to instances of UT? Yes.
+ //~ Can instances of OT be explicitly converted to instances of UT? Yes.
             //~ Waiting for explicit conversion operators,, the explicit conversion must be done through the underlying function
         //~ Can instances of OT be implicitly converted to instances of UT? No
 

Modified: sandbox/opaque/boost/opaque/public_opaque_class.hpp
==============================================================================
--- sandbox/opaque/boost/opaque/public_opaque_class.hpp (original)
+++ sandbox/opaque/boost/opaque/public_opaque_class.hpp 2010-09-26 17:13:03 EDT (Sun, 26 Sep 2010)
@@ -14,7 +14,6 @@
 #define BOOST_OPAQUE_PUBLIC_OPAQUE_CLASS_HPP
 
 #include <boost/opaque/combined_operators.hpp>
-#include <boost/opaque/public_opaque_type.hpp>
 
 #include <boost/type_traits/is_class.hpp>
 #include <boost/type_traits/is_base_of.hpp>
@@ -24,22 +23,64 @@
 
 namespace boost {
 
+ class base_public_opaque_type {};
+
+ template <typename T, bool B>
+ struct get_substituables;
+
+ template <typename T>
+ struct get_substituables<T,true> {
+ typedef typename mpl::push_front<typename T::substituables, T>::type type;
+ };
+
+ template <typename T>
+ struct get_substituables<T,false> {
+ typedef mpl::vector<T> type;
+ };
+
+ template <typename Final, typename UT, typename Base=base_new_type>
+ struct transitive_substituable;
+
+ namespace detail {
+
+ template <typename Final, typename UT, typename Base, bool B>
+ struct transitive_substituable_next_level;
+
+ template <typename Final, typename UT, typename Base>
+ struct transitive_substituable_next_level<Final, UT, Base, true>
+ : transitive_substituable<Final, typename UT::underlying_type, Base> { };
+
+ template <typename Final, typename UT, typename Base>
+ struct transitive_substituable_next_level<Final, UT, Base, false> : Base { };
+
+ }
+
+ template <typename Final, typename UT, typename Base>
+ struct transitive_substituable
+ : detail::transitive_substituable_next_level<Final, UT, Base,
+ mpl::and_<is_class<UT>, is_base_of<base_public_opaque_type, UT> >::value>
+ {
+ operator UT() const {
+ return Final::final(this).underlying();
+ }
+ };
+
 
     template <typename Final, typename T, typename Concepts=boost::mpl::vector0<>, typename Base=base_public_opaque_type>
     class public_opaque_class
         : public
             new_class< Final, T, Concepts,
- transitive_substituable<Final, T,
+ transitive_substituable<Final, T,
                     typename inherited_from_undelying<T>::template type<Final, T, Base>
- >
+ >
>
 
     {
         typedef
             new_class< Final, T, Concepts,
- transitive_substituable<Final, T,
+ transitive_substituable<Final, T,
                     typename inherited_from_undelying<T>::template type<Final, T, Base>
- >
+ >
>
         base_type;
 

Modified: sandbox/opaque/boost/opaque/public_opaque_type.hpp
==============================================================================
--- sandbox/opaque/boost/opaque/public_opaque_type.hpp (original)
+++ sandbox/opaque/boost/opaque/public_opaque_type.hpp 2010-09-26 17:13:03 EDT (Sun, 26 Sep 2010)
@@ -15,6 +15,7 @@
 
 #include <boost/opaque/combined_operators.hpp>
 #include <boost/opaque/new_class.hpp>
+#include <boost/opaque/public_opaque_class.hpp>
 
 #include <boost/type_traits/is_class.hpp>
 #include <boost/type_traits/is_base_of.hpp>
@@ -24,74 +25,15 @@
 
 namespace boost {
 
- class base_public_opaque_type {};
-
- template <typename T, bool B>
- struct get_substituables;
-
- template <typename T>
- struct get_substituables<T,true> {
- typedef typename mpl::push_front<typename T::substituables, T>::type type;
- };
-
- template <typename T>
- struct get_substituables<T,false> {
- typedef mpl::vector<T> type;
- };
-
- template <typename Final, typename UT, typename Base=base_new_type>
- struct transitive_substituable;
-
- namespace detail {
-
- template <typename Final, typename UT, typename Base, bool B>
- struct transitive_substituable_next_level;
-
- template <typename Final, typename UT, typename Base>
- struct transitive_substituable_next_level<Final, UT, Base, true>
- : transitive_substituable<Final, typename UT::underlying_type, Base> { };
-
- template <typename Final, typename UT, typename Base>
- struct transitive_substituable_next_level<Final, UT, Base, false> : Base { };
-
- }
-
- template <typename Final, typename UT, typename Base>
- struct transitive_substituable
- : detail::transitive_substituable_next_level<Final, UT, Base,
- mpl::and_<is_class<UT>, is_base_of<base_public_opaque_type, UT> >::value>
- {
- operator UT() const {
- return Final::final(this).underlying();
- }
- };
-
 
     template <typename T, typename Tag=void, typename Concepts=boost::mpl::vector0<>, typename Base=base_public_opaque_type>
     class public_opaque_type
- : public
- new_class< public_opaque_type<T,Tag,Concepts,Base>, T, Concepts,
- transitive_substituable<public_opaque_type<T,Tag,Concepts,Base>, T,
- typename inherited_from_undelying<T>::template type<public_opaque_type<T,Tag,Concepts,Base>, T, Base>
- >
- >
-
+ : public public_opaque_class< public_opaque_type<T,Tag,Concepts,Base>, T, Concepts, Base>
     {
- typedef
- new_class< public_opaque_type<T,Tag,Concepts,Base>, T, Concepts,
- transitive_substituable<public_opaque_type<T,Tag,Concepts,Base>, T,
- typename inherited_from_undelying<T>::template type<public_opaque_type<T,Tag,Concepts,Base>, T, Base>
- >
- >
- base_type;
-
+ typedef public_opaque_class< public_opaque_type<T,Tag,Concepts,Base>, T, Concepts, Base> base_type;
     protected:
         typedef public_opaque_type opaque_type_t;
     public:
- typedef typename get_substituables<T,
- mpl::and_<is_class<T>, is_base_of<base_public_opaque_type,T> >::value
- >::type substituables;
-
         //~ Can instances of UT be explicitly converted to instances of OT? Yes
         //~ Can instances of UT be implicitly converted to instances of OT? No
         //~ Can instances of OT be explicitly converted to instances of UT? Yes
@@ -103,10 +45,6 @@
         template <typename W>
         explicit public_opaque_type(W v) : base_type(v) {}
 
- //~ public_opaque_type & operator=(const opaque_type_t & rhs) {
- //~ this->val_ = rhs.val_; return *this;
- //~ }
-
     };
 
 }


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