]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/smart_ptr/test/allocate_unique_array_throws_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 >= 48000) && \
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
>&)
55 static unsigned instances
;
70 type
& operator=(const type
&);
73 unsigned type::instances
= 0;
78 boost::allocate_unique
<type
[]>(creator
<type
>(), 6);
79 BOOST_ERROR("allocate_unique did not throw");
81 BOOST_TEST(type::instances
== 0);
84 boost::allocate_unique
<type
[][2]>(creator
<type
>(), 3);
85 BOOST_ERROR("allocate_unique did not throw");
87 BOOST_TEST(type::instances
== 0);
90 boost::allocate_unique
<type
[6]>(creator
<>());
91 BOOST_ERROR("allocate_unique did not throw");
93 BOOST_TEST(type::instances
== 0);
96 boost::allocate_unique
<type
[3][2]>(creator
<>());
97 BOOST_ERROR("allocate_unique did not throw");
99 BOOST_TEST(type::instances
== 0);
102 boost::allocate_unique_noinit
<type
[]>(creator
<>(), 6);
103 BOOST_ERROR("allocate_unique_noinit did not throw");
105 BOOST_TEST(type::instances
== 0);
108 boost::allocate_unique_noinit
<type
[][2]>(creator
<>(), 3);
109 BOOST_ERROR("allocate_unique_noinit did not throw");
111 BOOST_TEST(type::instances
== 0);
114 boost::allocate_unique_noinit
<type
[6]>(creator
<>());
115 BOOST_ERROR("allocate_unique_noinit did not throw");
117 BOOST_TEST(type::instances
== 0);
120 boost::allocate_unique_noinit
<type
[3][2]>(creator
<>());
121 BOOST_ERROR("allocate_unique_noinit did not throw");
123 BOOST_TEST(type::instances
== 0);
125 return boost::report_errors();