Remove unnecessary expression test mechanisms

This commit is contained in:
LeonineKing1199
2021-12-08 13:59:11 -08:00
parent 05b795bc14
commit fefb6ad4c4

View File

@ -844,116 +844,6 @@ namespace boost {
}
}
////////////////////////////////////////////////////////////////////////////
// Expression test mechanism
//
// When SFINAE expressions are available, define
// BOOST_UNORDERED_HAS_FUNCTION which can check if a function call is
// supported by a class, otherwise define BOOST_UNORDERED_HAS_MEMBER which
// can detect if a class has the specified member, but not that it has the
// correct type, this is good enough for a passable impression of
// allocator_traits.
#if !defined(BOOST_NO_SFINAE_EXPR)
namespace boost {
namespace unordered {
namespace detail {
template <typename T, long unsigned int> struct expr_test;
template <typename T> struct expr_test<T, sizeof(char)> : T
{
};
}
}
}
#define BOOST_UNORDERED_CHECK_EXPRESSION(count, result, expression) \
template <typename U> \
static \
typename boost::unordered::detail::expr_test<BOOST_PP_CAT(choice, result), \
sizeof(for_expr_test(((expression), 0)))>::type \
test(BOOST_PP_CAT(choice, count))
#define BOOST_UNORDERED_DEFAULT_EXPRESSION(count, result) \
template <typename U> \
static BOOST_PP_CAT(choice, result)::type test(BOOST_PP_CAT(choice, count))
#define BOOST_UNORDERED_HAS_FUNCTION(name, thing, args, _) \
struct BOOST_PP_CAT(has_, name) \
{ \
template <typename U> static char for_expr_test(U const&); \
BOOST_UNORDERED_CHECK_EXPRESSION( \
1, 1, boost::unordered::detail::make<thing>().name args); \
BOOST_UNORDERED_DEFAULT_EXPRESSION(2, 2); \
\
enum \
{ \
value = sizeof(test<T>(choose())) == sizeof(choice1::type) \
}; \
}
#else
namespace boost {
namespace unordered {
namespace detail {
template <typename T> struct identity
{
typedef T type;
};
}
}
}
#define BOOST_UNORDERED_CHECK_MEMBER(count, result, name, member) \
\
typedef \
typename boost::unordered::detail::identity<member>::type BOOST_PP_CAT( \
check, count); \
\
template <BOOST_PP_CAT(check, count) e> struct BOOST_PP_CAT(test, count) \
{ \
typedef BOOST_PP_CAT(choice, result) type; \
}; \
\
template <class U> \
static typename BOOST_PP_CAT(test, count)<&U::name>::type test( \
BOOST_PP_CAT(choice, count))
#define BOOST_UNORDERED_DEFAULT_MEMBER(count, result) \
template <class U> \
static BOOST_PP_CAT(choice, result)::type test(BOOST_PP_CAT(choice, count))
#define BOOST_UNORDERED_HAS_MEMBER(name) \
struct BOOST_PP_CAT(has_, name) \
{ \
struct impl \
{ \
struct base_mixin \
{ \
int name; \
}; \
struct base : public T, public base_mixin \
{ \
}; \
\
BOOST_UNORDERED_CHECK_MEMBER(1, 1, name, int base_mixin::*); \
BOOST_UNORDERED_DEFAULT_MEMBER(2, 2); \
\
enum \
{ \
value = sizeof(choice2::type) == sizeof(test<base>(choose())) \
}; \
}; \
\
enum \
{ \
value = impl::value \
}; \
}
#endif
////////////////////////////////////////////////////////////////////////////
// TRAITS TYPE DETECTION MECHANISM
//