Unordered: More cleaning up.

Fix deprecated construct_impl and explicit namespaces in a few places.

[SVN r74766]
This commit is contained in:
Daniel James
2011-10-06 21:06:35 +00:00
parent 3a909c8747
commit 597d93537d
3 changed files with 47 additions and 31 deletions

View File

@ -133,7 +133,8 @@ namespace boost { namespace unordered { namespace detail {
#define BOOST_UNORDERED_HAS_FUNCTION(name, thing, args, _) \ #define BOOST_UNORDERED_HAS_FUNCTION(name, thing, args, _) \
struct BOOST_PP_CAT(has_, name) \ struct BOOST_PP_CAT(has_, name) \
{ \ { \
BOOST_UNORDERED_CHECK_EXPRESSION(1, 1, make< thing >().name args); \ BOOST_UNORDERED_CHECK_EXPRESSION(1, 1, \
boost::unordered::detail::make< thing >().name args); \
BOOST_UNORDERED_DEFAULT_EXPRESSION(2, 2); \ BOOST_UNORDERED_DEFAULT_EXPRESSION(2, 2); \
\ \
enum { value = sizeof(test<T>(choose())) == sizeof(choice1::type) };\ enum { value = sizeof(test<T>(choose())) == sizeof(choice1::type) };\
@ -149,7 +150,8 @@ namespace boost { namespace unordered { namespace detail {
#define BOOST_UNORDERED_CHECK_MEMBER(count, result, name, member) \ #define BOOST_UNORDERED_CHECK_MEMBER(count, result, name, member) \
\ \
typedef typename identity<member>::type BOOST_PP_CAT(check, count); \ typedef typename boost::unordered::detail::identity<member>::type \
BOOST_PP_CAT(check, count); \
\ \
template <BOOST_PP_CAT(check, count) e> \ template <BOOST_PP_CAT(check, count) e> \
struct BOOST_PP_CAT(test, count) { \ struct BOOST_PP_CAT(test, count) { \
@ -207,7 +209,8 @@ namespace boost { namespace unordered { namespace detail {
{ \ { \
enum { value = sizeof( \ enum { value = sizeof( \
boost::unordered::detail::is_private_type(( \ boost::unordered::detail::is_private_type(( \
make<wrap< thing > >().name args \ boost::unordered::detail::make<wrap< thing > >() \
.name args \
, 0))) == sizeof(yes_type) }; \ , 0))) == sizeof(yes_type) }; \
}; \ }; \
\ \
@ -329,12 +332,14 @@ namespace boost { namespace unordered { namespace detail {
#if BOOST_UNORDERED_HAVE_CALL_N_DETECTION #if BOOST_UNORDERED_HAVE_CALL_N_DETECTION
template <typename T, typename ValueType> template <typename T, typename ValueType>
BOOST_UNORDERED_HAS_FUNCTION( BOOST_UNORDERED_HAS_FUNCTION(
construct, U, (make<ValueType*>(), make<ValueType const>()), 2 construct, U, (
boost::unordered::detail::make<ValueType*>(),
boost::unordered::detail::make<ValueType const>()), 2
); );
template <typename T, typename ValueType> template <typename T, typename ValueType>
BOOST_UNORDERED_HAS_FUNCTION( BOOST_UNORDERED_HAS_FUNCTION(
destroy, U, (make<ValueType*>()), 1 destroy, U, (boost::unordered::detail::make<ValueType*>()), 1
); );
#else #else
template <typename T> template <typename T>
@ -345,31 +350,35 @@ namespace boost { namespace unordered { namespace detail {
#endif #endif
template <typename Alloc> template <typename Alloc>
inline typename boost::enable_if< inline typename boost::enable_if_c<
has_select_on_container_copy_construction<Alloc>, Alloc boost::unordered::detail::
has_select_on_container_copy_construction<Alloc>::value, Alloc
>::type call_select_on_container_copy_construction(const Alloc& rhs) >::type call_select_on_container_copy_construction(const Alloc& rhs)
{ {
return rhs.select_on_container_copy_construction(); return rhs.select_on_container_copy_construction();
} }
template <typename Alloc> template <typename Alloc>
inline typename boost::disable_if< inline typename boost::disable_if_c<
has_select_on_container_copy_construction<Alloc>, Alloc boost::unordered::detail::
has_select_on_container_copy_construction<Alloc>::value, Alloc
>::type call_select_on_container_copy_construction(const Alloc& rhs) >::type call_select_on_container_copy_construction(const Alloc& rhs)
{ {
return rhs; return rhs;
} }
template <typename SizeType, typename Alloc> template <typename SizeType, typename Alloc>
SizeType call_max_size(const Alloc& a, inline typename boost::enable_if_c<
typename boost::enable_if<has_max_size<Alloc>, void*>::type = 0) boost::unordered::detail::has_max_size<Alloc>::value, SizeType
>::type call_max_size(const Alloc& a)
{ {
return a.max_size(); return a.max_size();
} }
template <typename SizeType, typename Alloc> template <typename SizeType, typename Alloc>
SizeType call_max_size(const Alloc&, inline typename boost::disable_if_c<
typename boost::disable_if<has_max_size<Alloc>, void*>::type = 0) boost::unordered::detail::has_max_size<Alloc>::value, SizeType
>::type call_max_size(const Alloc&)
{ {
return std::numeric_limits<SizeType>::max(); return std::numeric_limits<SizeType>::max();
} }
@ -423,29 +432,33 @@ namespace boost { namespace unordered { namespace detail {
// Only supporting the basic copy constructor for now. // Only supporting the basic copy constructor for now.
template <typename T> template <typename T>
static void construct(Alloc& a, T* p, T const& x, typename static typename boost::enable_if_c<
boost::enable_if<has_construct<Alloc, T>, void*>::type = 0) boost::unordered::detail::has_construct<Alloc, T>::value>::type
construct(Alloc& a, T* p, T const& x)
{ {
a.construct(p, x); a.construct(p, x);
} }
template <typename T> template <typename T>
static void construct(Alloc&, T* p, T const& x, typename static typename boost::disable_if_c<
boost::disable_if<has_construct<Alloc, T>, void*>::type = 0) boost::unordered::detail::has_construct<Alloc, T>::value>::type
construct(Alloc&, T* p, T const& x)
{ {
new (p) T(x); new ((void*) p) T(x);
} }
template <typename T> template <typename T>
static void destroy(Alloc& a, T* p, typename static typename boost::enable_if_c<
boost::enable_if<has_destroy<Alloc, T>, void*>::type = 0) boost::unordered::detail::has_destroy<Alloc, T>::value>::type
destroy(Alloc& a, T* p)
{ {
a.destroy(p); a.destroy(p);
} }
template <typename T> template <typename T>
static void destroy(Alloc&, T* p, typename static typename boost::disable_if_c<
boost::disable_if<has_destroy<Alloc, T>, void*>::type = 0) boost::unordered::detail::has_destroy<Alloc, T>::value>::type
destroy(Alloc&, T* p)
{ {
boost::unordered::detail::destroy(p); boost::unordered::detail::destroy(p);
} }

View File

@ -160,7 +160,7 @@ BOOST_PP_REPEAT_FROM_TO(1, BOOST_UNORDERED_EMPLACE_LIMIT, BOOST_UNORDERED_EARGS,
boost::detail::if_true< boost::detail::if_true<
boost::is_class<T>::value boost::is_class<T>::value
>::BOOST_NESTED_TEMPLATE then < >::BOOST_NESTED_TEMPLATE then <
rv_ref_impl<T>, boost::unordered::detail::rv_ref_impl<T>,
please_ignore_this_overload please_ignore_this_overload
>::type >::type
{}; {};
@ -227,7 +227,8 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, std::tr1)
static choice3::type check(choice3, ...); static choice3::type check(choice3, ...);
enum { value = enum { value =
sizeof(check(choose(), make<A0>())) == sizeof(choice2::type) }; sizeof(check(choose(), boost::unordered::detail::make<A0>())) ==
sizeof(choice2::type) };
}; };
#endif #endif
@ -242,7 +243,8 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, std::tr1)
static choice3::type check(choice3, ...); static choice3::type check(choice3, ...);
enum { value = sizeof(check(choose(), make<A0>())) }; enum { value =
sizeof(check(choose(), boost::unordered::detail::make<A0>())) };
}; };
template <typename A, typename B, typename A0> template <typename A, typename B, typename A0>
@ -273,9 +275,9 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, std::tr1)
inline typename enable_if<piecewise3<A, B, A0>, void>::type inline typename enable_if<piecewise3<A, B, A0>, void>::type
construct_impl(std::pair<A, B>* address, A0&&, A1&& a1, A2&& a2) construct_impl(std::pair<A, B>* address, A0&&, A1&& a1, A2&& a2)
{ {
construct_from_tuple( boost::unordered::detail::construct_from_tuple(
boost::addressof(address->first), a1); boost::addressof(address->first), a1);
construct_from_tuple( boost::unordered::detail::construct_from_tuple(
boost::addressof(address->second), a2); boost::addressof(address->second), a2);
} }
@ -291,7 +293,7 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, std::tr1)
template <typename A, typename B, typename A0, typename A1, typename A2> template <typename A, typename B, typename A0, typename A1, typename A2>
inline typename enable_if<emulation3<A, B, A0>, void>::type inline typename enable_if<emulation3<A, B, A0>, void>::type
construct_impl(T* address, A0&& a0, A1&& a1, A2&& a2) construct_impl(std::pair<A, B>* address, A0&& a0, A1&& a1, A2&& a2)
{ {
new((void*) boost::addressof(address->first)) A(std::forward<A0>(a0)); new((void*) boost::addressof(address->first)) A(std::forward<A0>(a0));
new((void*) boost::addressof(address->second)) B( new((void*) boost::addressof(address->second)) B(
@ -345,9 +347,9 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, std::tr1)
construct_impl(std::pair<A, B>* address, construct_impl(std::pair<A, B>* address,
boost::unordered::detail::emplace_args3<A0, A1, A2> const& args) boost::unordered::detail::emplace_args3<A0, A1, A2> const& args)
{ {
construct_from_tuple( boost::unordered::detail::construct_from_tuple(
boost::addressof(address->first), args.a1); boost::addressof(address->first), args.a1);
construct_from_tuple( boost::unordered::detail::construct_from_tuple(
boost::addressof(address->second), args.a2); boost::addressof(address->second), args.a2);
} }

View File

@ -33,7 +33,8 @@ namespace detail {
static choice1::type test(T2 const&); static choice1::type test(T2 const&);
static choice2::type test(Key const&); static choice2::type test(Key const&);
enum { value = sizeof(test(make<T>())) == sizeof(choice2::type) }; enum { value = sizeof(test(boost::unordered::detail::make<T>())) ==
sizeof(choice2::type) };
typedef typename boost::detail::if_true<value>:: typedef typename boost::detail::if_true<value>::
BOOST_NESTED_TEMPLATE then<Key const&, no_key>::type type; BOOST_NESTED_TEMPLATE then<Key const&, no_key>::type type;