]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/container/test/slist_test.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / container / test / slist_test.cpp
index 9d0c17e5dec2fd2d9a17417d3706a693a3fb0896..08943448ade623312ad0ea8d7f8c016bc179b80c 100644 (file)
 
 using namespace boost::container;
 
-namespace boost {
-namespace container {
-
-//Explicit instantiation to detect compilation errors
-template class boost::container::slist
-   < test::movable_and_copyable_int
-   , test::simple_allocator<test::movable_and_copyable_int> >;
-
-template class boost::container::slist
-   < test::movable_and_copyable_int
-   , node_allocator<test::movable_and_copyable_int> >;
-
-}}
-
 class recursive_slist
 {
 public:
@@ -65,28 +51,6 @@ struct GetAllocatorCont
    };
 };
 
-template<class VoidAllocator>
-int test_cont_variants()
-{
-   typedef typename GetAllocatorCont<VoidAllocator>::template apply<int>::type MyCont;
-   typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::movable_int>::type MyMoveCont;
-   typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::movable_and_copyable_int>::type MyCopyMoveCont;
-   typedef typename GetAllocatorCont<VoidAllocator>::template apply<test::copyable_int>::type MyCopyCont;
-
-   if(test::list_test<MyCont, false>())
-      return 1;
-   if(test::list_test<MyMoveCont, false>())
-      return 1;
-   if(test::list_test<MyCopyMoveCont, false>())
-      return 1;
-   if(test::list_test<MyCopyMoveCont, false>())
-      return 1;
-   if(test::list_test<MyCopyCont, false>())
-      return 1;
-
-   return 0;
-}
-
 bool test_support_for_initializer_list()
 {
 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
@@ -201,16 +165,18 @@ int main ()
    ////////////////////////////////////
    //    Testing allocator implementations
    ////////////////////////////////////
-   //       std:allocator
-   if(test_cont_variants< std::allocator<void> >()){
-      std::cerr << "test_cont_variants< std::allocator<void> > failed" << std::endl;
+   if (test::list_test<slist<int, std::allocator<int> >, false>())
       return 1;
-   }
-   //       boost::container::node_allocator
-   if(test_cont_variants< node_allocator<void> >()){
-      std::cerr << "test_cont_variants< node_allocator<void> > failed" << std::endl;
+   if (test::list_test<slist<int>, false>())
+      return 1;
+   if (test::list_test<slist<int, node_allocator<int> >, false>())
+      return 1;
+   if (test::list_test<slist<test::movable_int>, false>())
+      return 1;
+   if (test::list_test<slist<test::movable_and_copyable_int>, false>())
+      return 1;
+   if (test::list_test<slist<test::copyable_int>, false>())
       return 1;
-   }
 
    ////////////////////////////////////
    //    Emplace testing
@@ -251,6 +217,73 @@ int main ()
          return 1;
       }
    }
+#ifndef BOOST_CONTAINER_NO_CXX17_CTAD
+   ////////////////////////////////////
+   //    Constructor Template Auto Deduction Tests
+   ////////////////////////////////////
+   {
+      auto gold = std::list{ 1, 2, 3 };
+      auto test = boost::container::slist(gold.begin(), gold.end());
+      if (test.size() != 3) {
+         return 1;
+      }
+      if (test.front() != 1)
+         return 1;
+      test.pop_front();
+      if (test.front() != 2)
+         return 1;
+      test.pop_front();
+      if (test.front() != 3)
+         return 1;
+      test.pop_front();
+   }
+   {
+      auto gold = std::list{ 1, 2, 3 };
+      auto test = boost::container::slist(gold.begin(), gold.end(), new_allocator<int>());
+      if (test.size() != 3) {
+         return 1;
+      }
+      if (test.front() != 1)
+         return 1;
+      test.pop_front();
+      if (test.front() != 2)
+         return 1;
+      test.pop_front();
+      if (test.front() != 3)
+         return 1;
+      test.pop_front();
+   }
+#endif
+
+   ////////////////////////////////////
+   //    has_trivial_destructor_after_move testing
+   ////////////////////////////////////
+   // default allocator
+   {
+      typedef boost::container::slist<int> cont;
+      typedef cont::allocator_type allocator_type;
+      typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
+      if (boost::has_trivial_destructor_after_move<cont>::value !=
+          boost::has_trivial_destructor_after_move<allocator_type>::value &&
+          boost::has_trivial_destructor_after_move<pointer>::value) {
+         std::cerr << "has_trivial_destructor_after_move(default allocator) test failed" << std::endl;
+         return 1;
+      }
+   }
+   // std::allocator
+   {
+      typedef boost::container::slist<int, std::allocator<int> > cont;
+      typedef cont::allocator_type allocator_type;
+      typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
+      if (boost::has_trivial_destructor_after_move<cont>::value !=
+          boost::has_trivial_destructor_after_move<allocator_type>::value &&
+          boost::has_trivial_destructor_after_move<pointer>::value) {
+         std::cerr << "has_trivial_destructor_after_move(std::allocator) test failed" << std::endl;
+         return 1;
+      }
+   }
+
+   return 0;
 }
 
 #include <boost/container/detail/config_end.hpp>