forked from boostorg/unordered
Merge pull request #58 from cmazakas/deprecate-allocator-traits-macro
Remove unnecessary `allocator_traits` macro
This commit is contained in:
@ -82,29 +82,6 @@
|
||||
#define BOOST_UNORDERED_EMPLACE_LIMIT 10
|
||||
#endif
|
||||
|
||||
// BOOST_UNORDERED_USE_ALLOCATOR_TRAITS - Pick which version of
|
||||
// allocator_traits to use.
|
||||
//
|
||||
// 0 = Own partial implementation
|
||||
// 1 = std::allocator_traits
|
||||
// 2 = boost::container::allocator_traits
|
||||
|
||||
#if !defined(BOOST_UNORDERED_USE_ALLOCATOR_TRAITS)
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
#define BOOST_UNORDERED_USE_ALLOCATOR_TRAITS 1
|
||||
#elif defined(BOOST_MSVC)
|
||||
#if BOOST_MSVC < 1400
|
||||
// Use container's allocator_traits for older versions of Visual
|
||||
// C++ as I don't test with them.
|
||||
#define BOOST_UNORDERED_USE_ALLOCATOR_TRAITS 2
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_UNORDERED_USE_ALLOCATOR_TRAITS)
|
||||
#define BOOST_UNORDERED_USE_ALLOCATOR_TRAITS 0
|
||||
#endif
|
||||
|
||||
// BOOST_UNORDERED_TUPLE_ARGS
|
||||
//
|
||||
// Maximum number of std::tuple members to support, or 0 if std::tuple
|
||||
@ -155,10 +132,7 @@
|
||||
#elif BOOST_COMP_GNUC && BOOST_COMP_GNUC < BOOST_VERSION_NUMBER(4, 7, 0)
|
||||
// Piecewise construction in GCC 4.6 doesn't work for uncopyable types.
|
||||
#define BOOST_UNORDERED_CXX11_CONSTRUCTION 0
|
||||
#elif BOOST_UNORDERED_USE_ALLOCATOR_TRAITS == 0 && \
|
||||
!defined(BOOST_NO_SFINAE_EXPR)
|
||||
#define BOOST_UNORDERED_CXX11_CONSTRUCTION 1
|
||||
#elif BOOST_UNORDERED_USE_ALLOCATOR_TRAITS == 1
|
||||
#elif !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
#define BOOST_UNORDERED_CXX11_CONSTRUCTION 1
|
||||
#endif
|
||||
#endif
|
||||
@ -870,188 +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
|
||||
//
|
||||
// Used to implement traits that use a type if present, or a
|
||||
// default otherwise.
|
||||
|
||||
#if defined(BOOST_MSVC) && BOOST_MSVC <= 1400
|
||||
|
||||
#define BOOST_UNORDERED_DEFAULT_TYPE_TMPLT(tname) \
|
||||
template <typename Tp, typename Default> struct default_type_##tname \
|
||||
{ \
|
||||
\
|
||||
template <typename X> \
|
||||
static choice1::type test(choice1, typename X::tname* = 0); \
|
||||
\
|
||||
template <typename X> static choice2::type test(choice2, void* = 0); \
|
||||
\
|
||||
struct DefaultWrap \
|
||||
{ \
|
||||
typedef Default tname; \
|
||||
}; \
|
||||
\
|
||||
enum \
|
||||
{ \
|
||||
value = (1 == sizeof(test<Tp>(choose()))) \
|
||||
}; \
|
||||
\
|
||||
typedef typename boost::detail::if_true<value>::BOOST_NESTED_TEMPLATE \
|
||||
then<Tp, DefaultWrap>::type::tname type; \
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
namespace boost {
|
||||
namespace unordered {
|
||||
namespace detail {
|
||||
template <typename T, typename T2> struct sfinae : T2
|
||||
{
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define BOOST_UNORDERED_DEFAULT_TYPE_TMPLT(tname) \
|
||||
template <typename Tp, typename Default> struct default_type_##tname \
|
||||
{ \
|
||||
\
|
||||
template <typename X> \
|
||||
static typename boost::unordered::detail::sfinae<typename X::tname, \
|
||||
choice1>::type test(choice1); \
|
||||
\
|
||||
template <typename X> static choice2::type test(choice2); \
|
||||
\
|
||||
struct DefaultWrap \
|
||||
{ \
|
||||
typedef Default tname; \
|
||||
}; \
|
||||
\
|
||||
enum \
|
||||
{ \
|
||||
value = (1 == sizeof(test<Tp>(choose()))) \
|
||||
}; \
|
||||
\
|
||||
typedef typename boost::detail::if_true<value>::BOOST_NESTED_TEMPLATE \
|
||||
then<Tp, DefaultWrap>::type::tname type; \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define BOOST_UNORDERED_DEFAULT_TYPE(T, tname, arg) \
|
||||
typename default_type_##tname<T, arg>::type
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Allocator traits
|
||||
|
@ -29,9 +29,6 @@ test-suite unordered
|
||||
[ run unordered/minimal_allocator.cpp ]
|
||||
[ run unordered/compile_set.cpp ]
|
||||
[ run unordered/compile_map.cpp ]
|
||||
[ run unordered/compile_map.cpp : :
|
||||
: <define>BOOST_UNORDERED_USE_ALLOCATOR_TRAITS=0
|
||||
: compile_map_unordered_allocator ]
|
||||
[ run unordered/noexcept_tests.cpp ]
|
||||
[ run unordered/link_test_1.cpp unordered/link_test_2.cpp ]
|
||||
[ run unordered/incomplete_test.cpp ]
|
||||
|
@ -137,8 +137,6 @@ namespace test {
|
||||
<< BOOST_UNORDERED_HAVE_PIECEWISE_CONSTRUCT << "\n" \
|
||||
<< "BOOST_UNORDERED_EMPLACE_LIMIT: " << BOOST_UNORDERED_EMPLACE_LIMIT \
|
||||
<< "\n" \
|
||||
<< "BOOST_UNORDERED_USE_ALLOCATOR_TRAITS: " \
|
||||
<< BOOST_UNORDERED_USE_ALLOCATOR_TRAITS << "\n" \
|
||||
<< "BOOST_UNORDERED_CXX11_CONSTRUCTION: " \
|
||||
<< BOOST_UNORDERED_CXX11_CONSTRUCTION << "\n\n" \
|
||||
<< std::flush; \
|
||||
|
@ -111,7 +111,7 @@ void test_empty_allocator()
|
||||
{
|
||||
typedef empty_allocator<int> allocator;
|
||||
typedef boost::unordered::detail::allocator_traits<allocator> traits;
|
||||
#if BOOST_UNORDERED_USE_ALLOCATOR_TRAITS == 1
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_STATIC_ASSERT((boost::is_same<traits::size_type,
|
||||
std::make_unsigned<std::ptrdiff_t>::type>::value));
|
||||
#else
|
||||
@ -153,7 +153,7 @@ void test_allocator1()
|
||||
{
|
||||
typedef allocator1<int> allocator;
|
||||
typedef boost::unordered::detail::allocator_traits<allocator> traits;
|
||||
#if BOOST_UNORDERED_USE_ALLOCATOR_TRAITS == 1
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_STATIC_ASSERT((boost::is_same<traits::size_type,
|
||||
std::make_unsigned<std::ptrdiff_t>::type>::value));
|
||||
#else
|
||||
|
@ -48,7 +48,7 @@ template <typename T> void test_simple_allocator()
|
||||
BOOST_STATIC_ASSERT(
|
||||
(boost::is_same<typename traits::difference_type, std::ptrdiff_t>::value));
|
||||
|
||||
#if BOOST_UNORDERED_USE_ALLOCATOR_TRAITS == 1
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_STATIC_ASSERT((boost::is_same<typename traits::size_type,
|
||||
std::make_unsigned<std::ptrdiff_t>::type>::value));
|
||||
#else
|
||||
|
Reference in New Issue
Block a user