mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-30 11:27:15 +02:00
Unordered: Alternative member detection.
Hopefully the Sun compiler will like this. [SVN r73757]
This commit is contained in:
@ -85,21 +85,27 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
template<typename T> convertible_from_anything(T const&);
|
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.
|
// Infrastructure for providing a default type for Tp::tname if absent.
|
||||||
#define BOOST_DEFAULT_TYPE_TMPLT(tname) \
|
#define BOOST_DEFAULT_TYPE_TMPLT(tname) \
|
||||||
template <typename Tp, typename Default> \
|
template <typename Tp, typename Default> \
|
||||||
struct default_type_ ## tname { \
|
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> \
|
enum { value = sizeof(test<Tp>(0)) == sizeof(yes_type) }; \
|
||||||
static char test(int, BOOST_DEDUCED_TYPENAME X::tname*); \
|
|
||||||
\
|
|
||||||
template <typename X> \
|
|
||||||
static int test(convertible_from_anything, void*); \
|
|
||||||
\
|
\
|
||||||
struct DefaultWrap { typedef Default tname; }; \
|
struct DefaultWrap { typedef Default tname; }; \
|
||||||
\
|
\
|
||||||
static const bool value = (1 == sizeof(test<Tp>(0, 0))); \
|
|
||||||
\
|
|
||||||
typedef BOOST_DEDUCED_TYPENAME \
|
typedef BOOST_DEDUCED_TYPENAME \
|
||||||
boost::detail::if_true<value>:: \
|
boost::detail::if_true<value>:: \
|
||||||
BOOST_NESTED_TEMPLATE then<Tp, DefaultWrap> \
|
BOOST_NESTED_TEMPLATE then<Tp, DefaultWrap> \
|
||||||
|
Reference in New Issue
Block a user