#include <boost/container/detail/config_begin.hpp>
#include <memory>
-#include <boost/move/move.hpp>
+#include <boost/move/utility_core.hpp>
#include <boost/container/vector.hpp>
#include <boost/container/deque.hpp>
#include <boost/container/list.hpp>
class SimpleAllocator
{
public:
- typedef Ty value_type;
- typedef typename std::allocator<Ty>::pointer pointer;
- typedef typename std::allocator<Ty>::size_type size_type;
+ typedef Ty value_type;
- SimpleAllocator(int value)
- : m_state(value)
- {}
+ SimpleAllocator(int value)
+ : m_state(value)
+ {}
- template <typename T>
- SimpleAllocator(const SimpleAllocator<T> &other)
- : m_state(other.m_state)
- {}
+ template <typename T>
+ SimpleAllocator(const SimpleAllocator<T> &other)
+ : m_state(other.m_state)
+ {}
- pointer allocate(size_type n)
- {
- return m_allocator.allocate(n);
- }
+ Ty* allocate(std::size_t n)
+ {
+ return m_allocator.allocate(n);
+ }
- void deallocate(pointer p, size_type n)
- {
- m_allocator.deallocate(p, n);
- }
+ void deallocate(Ty* p, std::size_t n)
+ {
+ m_allocator.deallocate(p, n);
+ }
int get_value() const
{ return m_state; }
private:
- int m_state;
- std::allocator<Ty> m_allocator;
+ int m_state;
+ std::allocator<Ty> m_allocator;
- template <typename T> friend class SimpleAllocator;
+ template <typename T> friend class SimpleAllocator;
};
class alloc_int
BOOST_MOVABLE_BUT_NOT_COPYABLE(alloc_int)
public:
- typedef SimpleAllocator<int> allocator_type;
-
- alloc_int(BOOST_RV_REF(alloc_int)other)
- : m_value(other.m_value), m_allocator(boost::move(other.m_allocator))
- {
- other.m_value = -1;
- }
-
- alloc_int(BOOST_RV_REF(alloc_int)other, const allocator_type &allocator)
- : m_value(other.m_value), m_allocator(allocator)
- {
- other.m_value = -1;
- }
-
- alloc_int(int value, const allocator_type &allocator)
- : m_value(value), m_allocator(allocator)
- {}
-
- alloc_int & operator=(BOOST_RV_REF(alloc_int)other)
- {
- other.m_value = other.m_value;
+ typedef SimpleAllocator<int> allocator_type;
+
+ alloc_int(BOOST_RV_REF(alloc_int)other)
+ : m_value(other.m_value), m_allocator(boost::move(other.m_allocator))
+ {
+ other.m_value = -1;
+ }
+
+ alloc_int(BOOST_RV_REF(alloc_int)other, const allocator_type &allocator)
+ : m_value(other.m_value), m_allocator(allocator)
+ {
+ other.m_value = -1;
+ }
+
+ alloc_int(int value, const allocator_type &allocator)
+ : m_value(value), m_allocator(allocator)
+ {}
+
+ alloc_int & operator=(BOOST_RV_REF(alloc_int)other)
+ {
+ other.m_value = other.m_value;
return *this;
- }
+ }
int get_allocator_state() const
{ return m_allocator.get_value(); }
{ return l.m_value == r.m_value; }
private:
- int m_value;
- allocator_type m_allocator;
+ int m_value;
+ allocator_type m_allocator;
};
using namespace ::boost::container;
//[multi]flat_map/set
typedef std::pair<alloc_int, alloc_int> FlatMapNode;
typedef scoped_allocator_adaptor<SimpleAllocator<FlatMapNode> > FlatMapAllocator;
-typedef flat_map<alloc_int, alloc_int, std::less<alloc_int>, MapAllocator> FlatMap;
+typedef flat_map<alloc_int, alloc_int, std::less<alloc_int>, FlatMapAllocator> FlatMap;
typedef flat_set<alloc_int, std::less<alloc_int>, AllocIntAllocator> FlatSet;
-typedef flat_multimap<alloc_int, alloc_int, std::less<alloc_int>, MapAllocator> FlatMultiMap;
+typedef flat_multimap<alloc_int, alloc_int, std::less<alloc_int>, FlatMapAllocator> FlatMultiMap;
typedef flat_multiset<alloc_int, std::less<alloc_int>, AllocIntAllocator> FlatMultiSet;
//vector, deque, list, slist, stable_vector.
: public Container
{
typedef typename Container::allocator_type allocator_type;
-
+
container_wrapper(const allocator_type &a)
: Container(a)
{}
{
typedef container_wrapper<Container> ContainerWrapper;
typedef typename ContainerWrapper::iterator iterator;
- ContainerWrapper c(SimpleAllocator<MapNode>(5));
+ ContainerWrapper c(SimpleAllocator<MapNode>(5));
c.clear();
- iterator it = c.emplace(c.cbegin(), 42);
+ iterator it = c.emplace(c.cbegin(), 42);
if(!test_value_and_state_equals(*it, 42, 5))
return false;
return 1;
if(!one_level_allocator_propagation_test<StableVector>())
return 1;
- return 0;
+ return 0;
}
#include <boost/container/detail/config_end.hpp>