Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65718 - sandbox/opaque/boost/opaque
From: vicente.botet_at_[hidden]
Date: 2010-10-02 03:01:54


Author: viboes
Date: 2010-10-02 03:01:52 EDT (Sat, 02 Oct 2010)
New Revision: 65718
URL: http://svn.boost.org/trac/boost/changeset/65718

Log:
Opaque:
* Extract transitive_explicit_substituable class

Added:
   sandbox/opaque/boost/opaque/transitive_explicit_substituable.hpp (contents, props changed)
Text files modified:
   sandbox/opaque/boost/opaque/private_opaque_class.hpp | 37 +++----------------------------------
   1 files changed, 3 insertions(+), 34 deletions(-)

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-10-02 03:01:52 EDT (Sat, 02 Oct 2010)
@@ -14,57 +14,26 @@
 #define BOOST_OPAQUE_PRIVATE_OPAQUE_CLASS_HPP
 
 #include <boost/opaque/combined_operators.hpp>
+#include <boost/opaque/transitive_explicit_substituable.hpp>
 
 #include <boost/type_traits/is_class.hpp>
 #include <boost/type_traits/is_base_of.hpp>
 #include <boost/mpl/and.hpp>
 
 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
             new_class< Final, T, Concepts,
- transitive_explicit_substituable<Final, T,
+ transitive_explicit_substituable<base_private_opaque_type>::template type<Final, T,
                     typename inherited_from_undelying<T>::template type<Final, T, Base>
>
>
     {
         typedef
             new_class< Final, T, Concepts,
- transitive_explicit_substituable<Final, T,
+ transitive_explicit_substituable<base_private_opaque_type>::template type<Final, T,
                     typename inherited_from_undelying<T>::template type<Final, T, Base>
>
>

Added: sandbox/opaque/boost/opaque/transitive_explicit_substituable.hpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/boost/opaque/transitive_explicit_substituable.hpp 2010-10-02 03:01:52 EDT (Sat, 02 Oct 2010)
@@ -0,0 +1,66 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2010.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/opaque for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_OPAQUE_TRANSITIVE_EXPLICIT_SUBSTITUABLE_HPP
+#define BOOST_OPAQUE_TRANSITIVE_EXPLICIT_SUBSTITUABLE_HPP
+
+#include <boost/opaque/combined_operators.hpp>
+
+#include <boost/type_traits/is_class.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/mpl/and.hpp>
+
+namespace boost {
+
+
+ template <typename BaseClass>
+ struct transitive_explicit_substituable;
+
+ namespace detail {
+
+ template <typename BaseClass, typename Final, typename UT, typename Base, bool B>
+ struct transitive_explicit_substituable_next_level;
+
+ template <typename BaseClass, typename Final, typename UT, typename Base>
+ struct transitive_explicit_substituable_next_level<BaseClass, Final, UT, Base, true>
+ : transitive_explicit_substituable<BaseClass>::template
+ type<Final, typename UT::underlying_type, Base>
+ {};
+ template <typename BaseClass, typename Final, typename UT, typename Base>
+ struct transitive_explicit_substituable_next_level<BaseClass, Final, UT, Base, false>
+ : Base
+ {};
+
+ }
+
+ template <typename BaseClass>
+ struct transitive_explicit_substituable {
+ template <typename Final, typename UT, typename Base>
+ struct type
+ #if defined(BOOST_NO_EXPLICIT_CONVERSION_OPERATORS)
+ : Base {};
+ #else
+ : detail::transitive_explicit_substituable_next_level<BaseClass, Final, UT, Base,
+ mpl::and_<is_class<UT>, is_base_of<BaseClass, UT> >::value>
+ {
+ explicit operator UT() const {
+ return Final::final(this).underlying();
+ }
+ };
+ #endif
+ };
+
+
+}
+
+
+#endif


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