]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/smart_ptr/test/allocate_unique_value_test.cpp
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 #include <boost/smart_ptr/allocate_unique.hpp>
13 #include <boost/core/lightweight_test.hpp>
15 template<class T
= void>
22 typedef creator
<U
> other
;
28 creator(const creator
<U
>&) { }
30 T
* allocate(std::size_t size
) {
31 return static_cast<T
*>(::operator new(sizeof(T
) * size
));
34 void deallocate(T
* ptr
, std::size_t) {
35 ::operator delete(ptr
);
39 template<class T
, class U
>
41 operator==(const creator
<T
>&, const creator
<U
>&)
46 template<class T
, class U
>
48 operator!=(const creator
<T
>&, const creator
<U
>&)
70 boost::alloc_deleter
<int, creator
<int> > > result
=
71 boost::allocate_unique
<int>(creator
<int>(), 1);
72 BOOST_TEST(result
.get() != 0);
73 BOOST_TEST(*result
== 1);
76 std::unique_ptr
<const int,
77 boost::alloc_deleter
<const int, creator
<> > > result
=
78 boost::allocate_unique
<const int>(creator
<>(), 1);
79 BOOST_TEST(result
.get() != 0);
80 BOOST_TEST(*result
== 1);
84 boost::alloc_deleter
<type
, creator
<type
> > > result
=
85 boost::allocate_unique
<type
>(creator
<type
>(), type(1, 2));
86 BOOST_TEST(result
.get() != 0);
87 BOOST_TEST(result
->sum() == 3);
90 std::unique_ptr
<const type
,
91 boost::alloc_deleter
<const type
, creator
<> > > result
=
92 boost::allocate_unique
<const type
>(creator
<>(), type(1, 2));
93 BOOST_TEST(result
.get() != 0);
94 BOOST_TEST(result
->sum() == 3);
96 return boost::report_errors();