mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-30 03:17:15 +02:00
Unordered: Some C++11 allocator_traits fixes.
Can now be used with g++ 4.7. Not activating by default yet. [SVN r76893]
This commit is contained in:
@ -202,7 +202,8 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
template <typename Alloc, typename T>
|
template <typename Alloc, typename T>
|
||||||
struct rebind_wrap
|
struct rebind_wrap
|
||||||
{
|
{
|
||||||
typedef typename std::allocator_traits<Alloc>::rebind_alloc<T> type;
|
typedef typename std::allocator_traits<Alloc>::
|
||||||
|
template rebind_alloc<T> type;
|
||||||
};
|
};
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -333,7 +333,7 @@ namespace minimal
|
|||||||
typedef std::size_t size_type;
|
typedef std::size_t size_type;
|
||||||
typedef std::ptrdiff_t difference_type;
|
typedef std::ptrdiff_t difference_type;
|
||||||
typedef void_ptr void_pointer;
|
typedef void_ptr void_pointer;
|
||||||
typedef void_const_ptr void_const_pointer;
|
typedef void_const_ptr const_void_pointer;
|
||||||
typedef ptr<T> pointer;
|
typedef ptr<T> pointer;
|
||||||
typedef const_ptr<T> const_pointer;
|
typedef const_ptr<T> const_pointer;
|
||||||
typedef T& reference;
|
typedef T& reference;
|
||||||
|
@ -90,7 +90,12 @@ void test_empty_allocator()
|
|||||||
{
|
{
|
||||||
typedef empty_allocator<int> allocator;
|
typedef empty_allocator<int> allocator;
|
||||||
typedef boost::unordered::detail::allocator_traits<allocator> traits;
|
typedef boost::unordered::detail::allocator_traits<allocator> traits;
|
||||||
|
#if BOOST_UNORDERED_USE_ALLOCATOR_TRAITS
|
||||||
|
BOOST_MPL_ASSERT((boost::is_same<traits::size_type,
|
||||||
|
std::make_unsigned<std::ptrdiff_t>::type>));
|
||||||
|
#else
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::size_type, std::size_t>));
|
BOOST_MPL_ASSERT((boost::is_same<traits::size_type, std::size_t>));
|
||||||
|
#endif
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::difference_type, std::ptrdiff_t>));
|
BOOST_MPL_ASSERT((boost::is_same<traits::difference_type, std::ptrdiff_t>));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::pointer, int*>));
|
BOOST_MPL_ASSERT((boost::is_same<traits::pointer, int*>));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::const_pointer, int const*>));
|
BOOST_MPL_ASSERT((boost::is_same<traits::const_pointer, int const*>));
|
||||||
@ -123,7 +128,12 @@ void test_allocator1()
|
|||||||
{
|
{
|
||||||
typedef allocator1<int> allocator;
|
typedef allocator1<int> allocator;
|
||||||
typedef boost::unordered::detail::allocator_traits<allocator> traits;
|
typedef boost::unordered::detail::allocator_traits<allocator> traits;
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::size_type, std::size_t>));
|
#if BOOST_UNORDERED_USE_ALLOCATOR_TRAITS
|
||||||
|
BOOST_MPL_ASSERT((boost::is_same<typename traits::size_type,
|
||||||
|
std::make_unsigned<std::ptrdiff_t>::type>));
|
||||||
|
#else
|
||||||
|
BOOST_MPL_ASSERT((boost::is_same<typename traits::size_type, std::size_t>));
|
||||||
|
#endif
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::difference_type, std::ptrdiff_t>));
|
BOOST_MPL_ASSERT((boost::is_same<traits::difference_type, std::ptrdiff_t>));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::pointer, int*>));
|
BOOST_MPL_ASSERT((boost::is_same<traits::pointer, int*>));
|
||||||
BOOST_MPL_ASSERT((boost::is_same<traits::const_pointer, int const*>));
|
BOOST_MPL_ASSERT((boost::is_same<traits::const_pointer, int const*>));
|
||||||
@ -186,6 +196,20 @@ struct ptr
|
|||||||
T& operator*() const { return *value_; }
|
T& operator*() const { return *value_; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct ptr<void>
|
||||||
|
{
|
||||||
|
void* value_;
|
||||||
|
ptr(void* v) : value_(v) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct ptr<const void>
|
||||||
|
{
|
||||||
|
void const* value_;
|
||||||
|
ptr(void const* v) : value_(v) {}
|
||||||
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct allocator3
|
struct allocator3
|
||||||
{
|
{
|
||||||
|
@ -51,7 +51,13 @@ void test_simple_allocator()
|
|||||||
//BOOST_MPL_ASSERT((boost::is_same<typename traits::const_void_pointer, void const*>));
|
//BOOST_MPL_ASSERT((boost::is_same<typename traits::const_void_pointer, void const*>));
|
||||||
|
|
||||||
BOOST_MPL_ASSERT((boost::is_same<typename traits::difference_type, std::ptrdiff_t>));
|
BOOST_MPL_ASSERT((boost::is_same<typename traits::difference_type, std::ptrdiff_t>));
|
||||||
|
|
||||||
|
#if BOOST_UNORDERED_USE_ALLOCATOR_TRAITS
|
||||||
|
BOOST_MPL_ASSERT((boost::is_same<typename traits::size_type,
|
||||||
|
std::make_unsigned<std::ptrdiff_t>::type>));
|
||||||
|
#else
|
||||||
BOOST_MPL_ASSERT((boost::is_same<typename traits::size_type, std::size_t>));
|
BOOST_MPL_ASSERT((boost::is_same<typename traits::size_type, std::size_t>));
|
||||||
|
#endif
|
||||||
|
|
||||||
BOOST_TEST(!traits::propagate_on_container_copy_assignment::value);
|
BOOST_TEST(!traits::propagate_on_container_copy_assignment::value);
|
||||||
BOOST_TEST(!traits::propagate_on_container_move_assignment::value);
|
BOOST_TEST(!traits::propagate_on_container_move_assignment::value);
|
||||||
|
Reference in New Issue
Block a user