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:
};
};
-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)
////////////////////////////////////
// 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
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>