|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r65595 - sandbox/opaque/boost/opaque
From: vicente.botet_at_[hidden]
Date: 2010-09-26 06:15:52
Author: viboes
Date: 2010-09-26 06:15:50 EDT (Sun, 26 Sep 2010)
New Revision: 65595
URL: http://svn.boost.org/trac/boost/changeset/65595
Log:
Opaque: Remove underlying_access base class and move these functions as static on the new_type class
Text files modified:
sandbox/opaque/boost/opaque/new_type.hpp | 51 ++++++++++++++++++---------------------
sandbox/opaque/boost/opaque/opaque_type.hpp | 1
sandbox/opaque/boost/opaque/private_opaque_type.hpp | 4 +-
sandbox/opaque/boost/opaque/public_opaque_type.hpp | 28 ++++++++++----------
4 files changed, 39 insertions(+), 45 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-26 06:15:50 EDT (Sun, 26 Sep 2010)
@@ -17,33 +17,9 @@
class base_new_type {};
- template <typename Final, typename UT, typename Base=base_new_type>
- struct underlying_access : Base {
- typedef Base base_type;
- underlying_access() {}
- underlying_access(UT val) : base_type(val) {}
- template <typename W>
- explicit underlying_access(W v)
- : base_type(v)
- {}
-
- Final const& final() const {
- return static_cast<Final const&>(*this);
- }
- Final& final() {
- return static_cast<Final&>(*this);
- }
- UT const& underlying() const {
- return final().underlying();
- }
- UT& underlying() {
- return final().underlying();
- }
- };
- // Base must inherit from underlying_access<>
// T the underlying type must be regular
- template <typename Final, typename T, typename Base=underlying_access<Final, T> >
+ template <typename Final, typename T, typename Base=base_new_type >
class new_type : public Base
{
public:
@@ -61,17 +37,36 @@
}
public:
- T const& underlying() const {
+ underlying_type const& underlying() const {
return val_;
}
- T& underlying() {
+ 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 Final const& final(F const* f) {
+ return static_cast<Final const&>(*f);
+ }
+ template<typename F>
+ Final& final(F* f) {
+ return static_cast<Final&>(*f);
+ }
+
};
template <typename T, typename Final, typename UT, typename Base >
- T new_type_static_cast(new_type<Final, UT, Base> const& v)
+ T opaque_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-26 06:15:50 EDT (Sun, 26 Sep 2010)
@@ -28,7 +28,6 @@
, opaque::ope::unary_plus< Final
, opaque::ope::unary_minus< Final
, Base
- //~ , underlying_access< Final, T, Base >
>
>
>
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 06:15:50 EDT (Sun, 26 Sep 2010)
@@ -26,14 +26,14 @@
class private_opaque_type : public
new_type< Final, T,
typename inherited_from_undelying<T, Final,
- underlying_access< Final, T, base_private_opaque_type >
+ base_private_opaque_type
>::type
>
{
typedef
new_type< Final, T,
typename inherited_from_undelying<T, Final,
- underlying_access< Final, T, base_private_opaque_type >
+ base_private_opaque_type
>::type
>
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 06:15:50 EDT (Sun, 26 Sep 2010)
@@ -38,30 +38,30 @@
typedef mpl::vector<T> type;
};
- template <typename UT, typename Base=base_new_type>
+ template <typename Final, typename UT, typename Base=base_new_type>
struct transitive_substituable;
namespace detail {
- template <typename UT, typename Base, bool B>
+ template <typename Final, typename UT, typename Base, bool B>
struct transitive_substituable_next_level;
- template <typename UT, typename Base>
- struct transitive_substituable_next_level<UT, Base, true>
- : transitive_substituable<typename UT::underlying_type, Base> { };
+ 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 UT, typename Base>
- struct transitive_substituable_next_level<UT, Base, false> : Base { };
+ template <typename Final, typename UT, typename Base>
+ struct transitive_substituable_next_level<Final, UT, Base, false> : Base { };
}
- template <typename UT, typename Base>
+ template <typename Final, typename UT, typename Base>
struct transitive_substituable
- : detail::transitive_substituable_next_level<UT, Base,
+ : 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 this->underlying();
+ return Final::final(this).underlying();
}
};
@@ -69,9 +69,9 @@
class public_opaque_type
: public
new_type< Final, T,
- transitive_substituable<T,
+ transitive_substituable<Final, T,
typename inherited_from_undelying<T, Final,
- underlying_access< Final, T, base_public_opaque_type >
+ base_public_opaque_type
>::type
>
>
@@ -79,9 +79,9 @@
{
typedef
new_type< Final, T,
- transitive_substituable<T,
+ transitive_substituable<Final, T,
typename inherited_from_undelying<T, Final,
- underlying_access< Final, T, base_public_opaque_type >
+ base_public_opaque_type
>::type
>
>
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