/* Copyright 2017 Glen Joseph Fernandes (glenjofe@gmail.com) Distributed under the Boost Software License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) */ #include #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \ !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \ !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) #include #include template struct creator { typedef T value_type; template struct rebind { typedef creator other; }; creator() { } template creator(const creator&) { } T* allocate(std::size_t size) { return static_cast(::operator new(sizeof(T) * size)); } void deallocate(T* ptr, std::size_t) { ::operator delete(ptr); } }; template inline bool operator==(const creator&, const creator&) { return true; } template inline bool operator!=(const creator&, const creator&) { return false; } int main() { { boost::local_shared_ptr result = boost::allocate_local_shared(creator(), 2, {0, 1}); BOOST_TEST(result[0][0] == 0); BOOST_TEST(result[0][1] == 1); BOOST_TEST(result[1][0] == 0); BOOST_TEST(result[1][1] == 1); } { boost::local_shared_ptr result = boost::allocate_local_shared(creator(), {0, 1}); BOOST_TEST(result[0][0] == 0); BOOST_TEST(result[0][1] == 1); BOOST_TEST(result[1][0] == 0); BOOST_TEST(result[1][1] == 1); } { boost::local_shared_ptr result = boost::allocate_local_shared(creator<>(), 2, {0, 1}); BOOST_TEST(result[0][0] == 0); BOOST_TEST(result[0][1] == 1); BOOST_TEST(result[1][0] == 0); BOOST_TEST(result[1][1] == 1); } { boost::local_shared_ptr result = boost::allocate_local_shared(creator<>(), {0, 1}); BOOST_TEST(result[0][0] == 0); BOOST_TEST(result[0][1] == 1); BOOST_TEST(result[1][0] == 0); BOOST_TEST(result[1][1] == 1); } return boost::report_errors(); } #else int main() { return 0; } #endif