Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65604 - sandbox/opaque/boost/opaque
From: vicente.botet_at_[hidden]
Date: 2010-09-26 09:22:52


Author: viboes
Date: 2010-09-26 09:22:50 EDT (Sun, 26 Sep 2010)
New Revision: 65604
URL: http://svn.boost.org/trac/boost/changeset/65604

Log:
Opaque: Add transitive_explicit_substituable
Text files modified:
   sandbox/opaque/boost/opaque/combined_operators.hpp | 4 ++--
   sandbox/opaque/boost/opaque/opaque.hpp | 8 ++------
   sandbox/opaque/boost/opaque/private_opaque_type.hpp | 36 ++++++++++++++++++++++++++++++++++--
   3 files changed, 38 insertions(+), 10 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 09:22:50 EDT (Sun, 26 Sep 2010)
@@ -20,10 +20,10 @@
 namespace boost {
 
 namespace opaque {
-
+
     template <typename Final, typename Base=base_new_type>
     struct equality_comparable1 : boost::equality_comparable1<Final, ope::equal<Final, Base> > {};
-
+
     template <typename Final, typename Base=base_new_type>
     struct less_than_comparable1 : boost::less_than_comparable1<Final, ope::less_than<Final, Base> > {};
 

Modified: sandbox/opaque/boost/opaque/opaque.hpp
==============================================================================
--- sandbox/opaque/boost/opaque/opaque.hpp (original)
+++ sandbox/opaque/boost/opaque/opaque.hpp 2010-09-26 09:22:50 EDT (Sun, 26 Sep 2010)
@@ -25,16 +25,12 @@
 #define BOOST_OPAQUE_STATIC_ASSERT(CND, MSG, TYPES) \
     BOOST_MPL_ASSERT_MSG(boost::mpl::bool_< (CND) >::type::value, MSG, TYPES)
 
+
 namespace boost {
- template <typename T, typename U>
- T opaque_static_cast(U v)
- {
- return static_cast<T>(v);
- }
 
     #if 0
     template <typename T, typename UT, typename OT>
- T opaque_static_cast<T, private_opaque_type<OT,UT> >(private_opaque_type<OT,UT> const&ot)
+ T opaque_static_cast(private_opaque_type<OT,UT> const&ot)
     {
         return static_cast<T>(ot.underlying());
     }

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 09:22:50 EDT (Sun, 26 Sep 2010)
@@ -22,6 +22,37 @@
 
     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)
+ {};
+#else
+ : detail::transitive_explicit_substituable_next_level<Final, UT, Base,
+ mpl::and_<is_class<UT>, is_base_of<base_public_opaque_type, UT> >::value>
+ {
+ explicit operator UT() const {
+ return Final::final(this).underlying();
+ }
+ };
+#endif
+
     template <typename Final, typename T>
     class private_opaque_type : public
             new_type< Final, T,
@@ -42,8 +73,9 @@
     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, throogh the underlying function
- //~ Can instances of OT be implicitly 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
 
         private_opaque_type() {};
         private_opaque_type(const opaque_type_t & rhs) : base_type(rhs.val_) {}


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