2 Copyright 2019 Glen Joseph Fernandes
5 Distributed under the Boost Software License, Version 1.0.
6 (http://www.boost.org/LICENSE_1_0.txt)
8 #include <boost/config.hpp>
9 #if (!defined(BOOST_LIBSTDCXX_VERSION) || \
10 BOOST_LIBSTDCXX_VERSION >= 46000) && \
11 !defined(BOOST_NO_CXX11_SMART_PTR) && \
12 !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
13 #include <boost/smart_ptr/allocate_unique.hpp>
14 #include <boost/core/lightweight_test.hpp>
16 template<class T = void>
23 typedef creator<U> other;
29 creator(const creator<U>&) { }
31 T* allocate(std::size_t size) {
32 return static_cast<T*>(::operator new(sizeof(T) * size));
35 void deallocate(T* ptr, std::size_t) {
36 ::operator delete(ptr);
40 template<class T, class U>
42 operator==(const creator<T>&, const creator<U>&)
47 template<class T, class U>
49 operator!=(const creator<T>&, const creator<U>&)
63 boost::alloc_deleter<type, creator<type> > > result =
64 boost::allocate_unique<type>(creator<type>(), { 1, 2 });
65 BOOST_TEST(result.get() != 0);
66 BOOST_TEST(result->x == 1);
67 BOOST_TEST(result->y == 2);
70 std::unique_ptr<const type,
71 boost::alloc_deleter<const type, creator<> > > result =
72 boost::allocate_unique<const type>(creator<>(), { 1, 2 });
73 BOOST_TEST(result.get() != 0);
74 BOOST_TEST(result->x == 1);
75 BOOST_TEST(result->y == 2);
77 return boost::report_errors();