Imported Upstream version 1.57.0
[platform/upstream/boost.git] / libs / container / test / scoped_allocator_usage_test.cpp
index bb841a2..111d12a 100644 (file)
@@ -1,7 +1,7 @@
 #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>
@@ -19,37 +19,35 @@ template <typename Ty>
 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
@@ -59,29 +57,29 @@ 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();  }
@@ -96,8 +94,8 @@ class alloc_int
    {  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;
@@ -116,9 +114,9 @@ typedef multiset<alloc_int, std::less<alloc_int>, AllocIntAllocator> MultiSet;
 //[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.
@@ -240,7 +238,7 @@ struct container_wrapper
    : public Container
 {
    typedef typename Container::allocator_type   allocator_type;
-  
+
    container_wrapper(const allocator_type &a)
       : Container(a)
    {}
@@ -347,10 +345,10 @@ bool one_level_allocator_propagation_test()
 {
    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;
@@ -389,7 +387,7 @@ int main()
       return 1;
    if(!one_level_allocator_propagation_test<StableVector>())
       return 1;
-       return 0;
+   return 0;
 }
 
 #include <boost/container/detail/config_end.hpp>