////////////////////////////////////////////////////////////////////////////// // // (C) Copyright Ion Gaztanaga 2026. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org/libs/container for documentation. // ////////////////////////////////////////////////////////////////////////////// #include //[doc_void_allocator #include #include #include #include #include //=#include int main() { using namespace boost::container; // // void as Allocator template argument // //Allocator argument is void: the library selects its default allocator. vector v_default; // Allocator defaults to void vector v_explicit_void; // Explicit void map m_default; // Allocator defaults to void map, void> m_explicit_void; //Same types v_default.push_back(1); v_explicit_void = v_default; m_default[3] = 3.0; m_explicit_void = m_default; // // Automatic rebinding with allocator::value_type == void, // typedef pmr::polymorphic_allocator pmr_void_t; typedef vector vector_alloc_of_void_t; typedef map, pmr_void_t > map_alloc_of_void_t; typedef std::pair map_value_t; /*<-*/ BOOST_CONTAINER_STATIC_ASSERT ((dtl::is_same< vector_alloc_of_void_t::allocator_type , pmr::polymorphic_allocator >::value)); BOOST_CONTAINER_STATIC_ASSERT ((dtl::is_same< map_alloc_of_void_t::allocator_type , pmr::polymorphic_allocator >::value)); /*->*/ //Container::allocator_type is the expected type //=static_assert //= (std::is_same< vector_alloc_of_void_t >::allocator_type, pmr::polymorphic_allocator >::value); //=static_assert //= (std::is_same< map_alloc_of_void_t >::allocator_type, pmr::polymorphic_allocator >::value); //Usually the Allocator type is convertible to the rebound allocator, no need //to explicitly rebind it. pmr_void_t alloc; vector_alloc_of_void_t v(alloc); map_alloc_of_void_t m(std::less(), alloc); return 0; } //]