1 /* 2 Copyright 2020 Glen Joseph Fernandes 3 (glenjofe@gmail.com) 4 5 Distributed under the Boost Software License, Version 1.0. 6 (http://www.boost.org/LICENSE_1_0.txt) 7 */ 8 #include <boost/core/allocator_access.hpp> 9 #include <boost/core/lightweight_test.hpp> 10 11 template<class T> 12 struct A1 { 13 typedef T value_type; A1A114 A1(int n) 15 : value(n) { } 16 int value; 17 }; 18 19 #if !defined(BOOST_NO_CXX11_ALLOCATOR) 20 template<class T> 21 struct A2 { 22 typedef T value_type; A2A223 A2(int n) 24 : value(n) { } select_on_container_copy_constructionA225 A2 select_on_container_copy_construction() const { 26 return A2(value + 1); 27 } 28 int value; 29 }; 30 #endif 31 main()32int main() 33 { 34 BOOST_TEST_EQ(1, boost:: 35 allocator_select_on_container_copy_construction(A1<int>(1)).value); 36 #if !defined(BOOST_NO_CXX11_ALLOCATOR) 37 BOOST_TEST_EQ(2, boost:: 38 allocator_select_on_container_copy_construction(A2<int>(1)).value); 39 #endif 40 return boost::report_errors(); 41 } 42