mirror of
https://github.com/boostorg/unordered.git
synced 2025-05-11 13:34:06 +00:00
Stricter about rebinding the allocator
This commit is contained in:
parent
ddee1b686a
commit
c0b72d97b3
@ -2484,10 +2484,10 @@ struct table : boost::unordered::detail::functions<typename Types::hasher,
|
||||
functions;
|
||||
typedef typename functions::set_hash_functions set_hash_functions;
|
||||
|
||||
typedef typename Types::allocator allocator;
|
||||
typedef typename boost::unordered::detail::rebind_wrap<allocator,
|
||||
typedef typename Types::value_allocator value_allocator;
|
||||
typedef typename boost::unordered::detail::rebind_wrap<value_allocator,
|
||||
node>::type node_allocator;
|
||||
typedef typename boost::unordered::detail::rebind_wrap<allocator,
|
||||
typedef typename boost::unordered::detail::rebind_wrap<value_allocator,
|
||||
bucket>::type bucket_allocator;
|
||||
typedef boost::unordered::detail::allocator_traits<node_allocator>
|
||||
node_allocator_traits;
|
||||
|
@ -13,14 +13,17 @@ template <typename A, typename K, typename M, typename H, typename P> struct map
|
||||
{
|
||||
typedef boost::unordered::detail::map<A, K, M, H, P> types;
|
||||
|
||||
typedef A allocator;
|
||||
typedef std::pair<K const, M> value_type;
|
||||
typedef H hasher;
|
||||
typedef P key_equal;
|
||||
typedef K key_type;
|
||||
|
||||
typedef boost::unordered::detail::allocator_traits<allocator> traits;
|
||||
typedef boost::unordered::detail::pick_node<allocator, value_type> pick;
|
||||
typedef typename ::boost::unordered::detail::rebind_wrap<A,
|
||||
value_type>::type value_allocator;
|
||||
typedef boost::unordered::detail::allocator_traits<value_allocator>
|
||||
value_allocator_traits;
|
||||
|
||||
typedef boost::unordered::detail::pick_node<A, value_type> pick;
|
||||
typedef typename pick::node node;
|
||||
typedef typename pick::bucket bucket;
|
||||
typedef typename pick::link_pointer link_pointer;
|
||||
@ -44,15 +47,17 @@ struct multimap
|
||||
{
|
||||
typedef boost::unordered::detail::multimap<A, K, M, H, P> types;
|
||||
|
||||
typedef A allocator;
|
||||
typedef std::pair<K const, M> value_type;
|
||||
typedef H hasher;
|
||||
typedef P key_equal;
|
||||
typedef K key_type;
|
||||
|
||||
typedef boost::unordered::detail::allocator_traits<allocator> traits;
|
||||
typedef boost::unordered::detail::pick_grouped_node<allocator, value_type>
|
||||
pick;
|
||||
typedef typename ::boost::unordered::detail::rebind_wrap<A,
|
||||
value_type>::type value_allocator;
|
||||
typedef boost::unordered::detail::allocator_traits<value_allocator>
|
||||
value_allocator_traits;
|
||||
|
||||
typedef boost::unordered::detail::pick_grouped_node<A, value_type> pick;
|
||||
typedef typename pick::node node;
|
||||
typedef typename pick::bucket bucket;
|
||||
typedef typename pick::link_pointer link_pointer;
|
||||
|
@ -13,14 +13,17 @@ template <typename A, typename T, typename H, typename P> struct set
|
||||
{
|
||||
typedef boost::unordered::detail::set<A, T, H, P> types;
|
||||
|
||||
typedef A allocator;
|
||||
typedef T value_type;
|
||||
typedef H hasher;
|
||||
typedef P key_equal;
|
||||
typedef T key_type;
|
||||
|
||||
typedef boost::unordered::detail::allocator_traits<allocator> traits;
|
||||
typedef boost::unordered::detail::pick_node<allocator, value_type> pick;
|
||||
typedef typename ::boost::unordered::detail::rebind_wrap<A,
|
||||
value_type>::type value_allocator;
|
||||
typedef boost::unordered::detail::allocator_traits<value_allocator>
|
||||
value_allocator_traits;
|
||||
|
||||
typedef boost::unordered::detail::pick_node<A, value_type> pick;
|
||||
typedef typename pick::node node;
|
||||
typedef typename pick::bucket bucket;
|
||||
typedef typename pick::link_pointer link_pointer;
|
||||
@ -42,15 +45,17 @@ template <typename A, typename T, typename H, typename P> struct multiset
|
||||
{
|
||||
typedef boost::unordered::detail::multiset<A, T, H, P> types;
|
||||
|
||||
typedef A allocator;
|
||||
typedef T value_type;
|
||||
typedef H hasher;
|
||||
typedef P key_equal;
|
||||
typedef T key_type;
|
||||
|
||||
typedef boost::unordered::detail::allocator_traits<allocator> traits;
|
||||
typedef boost::unordered::detail::pick_grouped_node<allocator, value_type>
|
||||
pick;
|
||||
typedef typename ::boost::unordered::detail::rebind_wrap<A,
|
||||
value_type>::type value_allocator;
|
||||
typedef boost::unordered::detail::allocator_traits<value_allocator>
|
||||
value_allocator_traits;
|
||||
|
||||
typedef boost::unordered::detail::pick_grouped_node<A, value_type> pick;
|
||||
typedef typename pick::node node;
|
||||
typedef typename pick::bucket bucket;
|
||||
typedef typename pick::link_pointer link_pointer;
|
||||
|
@ -50,12 +50,12 @@ template <class K, class T, class H, class P, class A> class unordered_map
|
||||
|
||||
private:
|
||||
typedef boost::unordered::detail::map<A, K, T, H, P> types;
|
||||
typedef typename types::traits allocator_traits;
|
||||
typedef typename types::value_allocator_traits value_allocator_traits;
|
||||
typedef typename types::table table;
|
||||
|
||||
public:
|
||||
typedef typename allocator_traits::pointer pointer;
|
||||
typedef typename allocator_traits::const_pointer const_pointer;
|
||||
typedef typename value_allocator_traits::pointer pointer;
|
||||
typedef typename value_allocator_traits::const_pointer const_pointer;
|
||||
|
||||
typedef value_type& reference;
|
||||
typedef value_type const& const_reference;
|
||||
@ -462,12 +462,12 @@ template <class K, class T, class H, class P, class A> class unordered_multimap
|
||||
|
||||
private:
|
||||
typedef boost::unordered::detail::multimap<A, K, T, H, P> types;
|
||||
typedef typename types::traits allocator_traits;
|
||||
typedef typename types::value_allocator_traits value_allocator_traits;
|
||||
typedef typename types::table table;
|
||||
|
||||
public:
|
||||
typedef typename allocator_traits::pointer pointer;
|
||||
typedef typename allocator_traits::const_pointer const_pointer;
|
||||
typedef typename value_allocator_traits::pointer pointer;
|
||||
typedef typename value_allocator_traits::const_pointer const_pointer;
|
||||
|
||||
typedef value_type& reference;
|
||||
typedef value_type const& const_reference;
|
||||
|
@ -47,12 +47,12 @@ template <class T, class H, class P, class A> class unordered_set
|
||||
|
||||
private:
|
||||
typedef boost::unordered::detail::set<A, T, H, P> types;
|
||||
typedef typename types::traits allocator_traits;
|
||||
typedef typename types::value_allocator_traits value_allocator_traits;
|
||||
typedef typename types::table table;
|
||||
|
||||
public:
|
||||
typedef typename allocator_traits::pointer pointer;
|
||||
typedef typename allocator_traits::const_pointer const_pointer;
|
||||
typedef typename value_allocator_traits::pointer pointer;
|
||||
typedef typename value_allocator_traits::const_pointer const_pointer;
|
||||
|
||||
typedef value_type& reference;
|
||||
typedef value_type const& const_reference;
|
||||
@ -447,12 +447,12 @@ template <class T, class H, class P, class A> class unordered_multiset
|
||||
|
||||
private:
|
||||
typedef boost::unordered::detail::multiset<A, T, H, P> types;
|
||||
typedef typename types::traits allocator_traits;
|
||||
typedef typename types::value_allocator_traits value_allocator_traits;
|
||||
typedef typename types::table table;
|
||||
|
||||
public:
|
||||
typedef typename allocator_traits::pointer pointer;
|
||||
typedef typename allocator_traits::const_pointer const_pointer;
|
||||
typedef typename value_allocator_traits::pointer pointer;
|
||||
typedef typename value_allocator_traits::const_pointer const_pointer;
|
||||
|
||||
typedef value_type& reference;
|
||||
typedef value_type const& const_reference;
|
||||
|
@ -441,6 +441,74 @@ template <class T> class allocator
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class T> class allocator<T const>
|
||||
{
|
||||
public:
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef void_ptr void_pointer;
|
||||
typedef void_const_ptr const_void_pointer;
|
||||
// Maybe these two should be const_ptr<T>
|
||||
typedef ptr<T const> pointer;
|
||||
typedef const_ptr<T const> const_pointer;
|
||||
typedef T const& reference;
|
||||
typedef T const& const_reference;
|
||||
typedef T const value_type;
|
||||
|
||||
template <class U> struct rebind
|
||||
{
|
||||
typedef allocator<U> other;
|
||||
};
|
||||
|
||||
allocator() {}
|
||||
template <class Y> allocator(allocator<Y> const&) {}
|
||||
allocator(allocator const&) {}
|
||||
~allocator() {}
|
||||
|
||||
const_pointer address(const_reference r) { return const_pointer(&r); }
|
||||
|
||||
pointer allocate(size_type n)
|
||||
{
|
||||
return pointer(static_cast<T const*>(::operator new(n * sizeof(T))));
|
||||
}
|
||||
|
||||
template <class Y> pointer allocate(size_type n, const_ptr<Y>)
|
||||
{
|
||||
return pointer(static_cast<T const*>(::operator new(n * sizeof(T))));
|
||||
}
|
||||
|
||||
void deallocate(pointer p, size_type) { ::operator delete((void*)p.ptr_); }
|
||||
|
||||
void construct(T const* p, T const& t) { new ((void*)p) T(t); }
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template <class... Args>
|
||||
void construct(T const* p, BOOST_FWD_REF(Args)... args)
|
||||
{
|
||||
new ((void*)p) T(boost::forward<Args>(args)...);
|
||||
}
|
||||
#endif
|
||||
|
||||
void destroy(T const* p) { p->~T(); }
|
||||
|
||||
size_type max_size() const { return 1000; }
|
||||
|
||||
#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) || \
|
||||
BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
public:
|
||||
allocator& operator=(allocator const&) { return *this; }
|
||||
#else
|
||||
private:
|
||||
allocator& operator=(allocator const&);
|
||||
#endif
|
||||
#if BOOST_UNORDERED_CHECK_ADDR_OPERATOR_NOT_USED
|
||||
ampersand_operator_used operator&() const
|
||||
{
|
||||
return ampersand_operator_used();
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline bool operator==(allocator<T> const&, allocator<T> const&)
|
||||
{
|
||||
|
@ -20,19 +20,19 @@
|
||||
// Explicit instantiation to catch compile-time errors
|
||||
|
||||
template class boost::unordered_map<int, int, boost::hash<int>,
|
||||
std::equal_to<int>, test::minimal::allocator<std::pair<int const, int> > >;
|
||||
std::equal_to<int>, test::minimal::allocator<int> >;
|
||||
template class boost::unordered_multimap<int const, int const, boost::hash<int>,
|
||||
std::equal_to<int>, test::minimal::allocator<std::pair<int const, int> > >;
|
||||
std::equal_to<int>, test::minimal::allocator<int> >;
|
||||
|
||||
template class boost::unordered_map<test::minimal::assignable const,
|
||||
test::minimal::default_assignable const,
|
||||
test::minimal::hash<test::minimal::assignable>,
|
||||
test::minimal::equal_to<test::minimal::assignable>,
|
||||
test::minimal::allocator<test::minimal::assignable> >;
|
||||
test::minimal::allocator<int> >;
|
||||
template class boost::unordered_multimap<test::minimal::assignable,
|
||||
test::minimal::assignable, test::minimal::hash<test::minimal::assignable>,
|
||||
test::minimal::equal_to<test::minimal::assignable>,
|
||||
test::minimal::allocator<test::minimal::assignable> >;
|
||||
test::minimal::allocator<int> >;
|
||||
|
||||
UNORDERED_AUTO_TEST(test0)
|
||||
{
|
||||
|
@ -27,11 +27,11 @@ template class boost::unordered_multiset<int const, boost::hash<int>,
|
||||
template class boost::unordered_set<test::minimal::assignable const,
|
||||
test::minimal::hash<test::minimal::assignable>,
|
||||
test::minimal::equal_to<test::minimal::assignable>,
|
||||
test::minimal::allocator<test::minimal::assignable> >;
|
||||
test::minimal::allocator<int> >;
|
||||
template class boost::unordered_multiset<test::minimal::assignable,
|
||||
test::minimal::hash<test::minimal::assignable>,
|
||||
test::minimal::equal_to<test::minimal::assignable>,
|
||||
test::minimal::allocator<test::minimal::assignable> >;
|
||||
test::minimal::allocator<int> >;
|
||||
|
||||
UNORDERED_AUTO_TEST(test0)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user