Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73757 - trunk/boost/unordered/detail
From: dnljms_at_[hidden]
Date: 2011-08-14 14:53:50


Author: danieljames
Date: 2011-08-14 14:53:50 EDT (Sun, 14 Aug 2011)
New Revision: 73757
URL: http://svn.boost.org/trac/boost/changeset/73757

Log:
Unordered: Alternative member detection.

Hopefully the Sun compiler will like this.
Text files modified:
   trunk/boost/unordered/detail/allocator_helpers.hpp | 20 +++++++++++++-------
   1 files changed, 13 insertions(+), 7 deletions(-)

Modified: trunk/boost/unordered/detail/allocator_helpers.hpp
==============================================================================
--- trunk/boost/unordered/detail/allocator_helpers.hpp (original)
+++ trunk/boost/unordered/detail/allocator_helpers.hpp 2011-08-14 14:53:50 EDT (Sun, 14 Aug 2011)
@@ -85,21 +85,27 @@
         template<typename T> convertible_from_anything(T const&);
     };
 
+ typedef char (&no_type)[1];
+ typedef char (&yes_type)[2];
+
+ template <typename T> struct sfinae {
+ typedef yes_type type;
+ };
+
     // Infrastructure for providing a default type for Tp::tname if absent.
     #define BOOST_DEFAULT_TYPE_TMPLT(tname) \
         template <typename Tp, typename Default> \
         struct default_type_ ## tname { \
+ template <typename T> \
+ static BOOST_DEDUCED_TYPENAME sfinae< \
+ BOOST_DEDUCED_TYPENAME T::tname>::type test(int); \
+ template <typename T> \
+ static no_type test(...); \
                                                                             \
- template <typename X> \
- static char test(int, BOOST_DEDUCED_TYPENAME X::tname*); \
- \
- template <typename X> \
- static int test(convertible_from_anything, void*); \
+ enum { value = sizeof(test<Tp>(0)) == sizeof(yes_type) }; \
                                                                             \
             struct DefaultWrap { typedef Default tname; }; \
                                                                             \
- static const bool value = (1 == sizeof(test<Tp>(0, 0))); \
- \
             typedef BOOST_DEDUCED_TYPENAME \
                 boost::detail::if_true<value>:: \
                 BOOST_NESTED_TEMPLATE then<Tp, DefaultWrap> \


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