]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/smart_ptr/test/allocate_shared_array_throws_test.cpp
2 Copyright 2012-2015 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/core/lightweight_test.hpp>
9 #include <boost/smart_ptr/make_shared.hpp>
11 template<class T
= void>
17 typedef creator
<U
> other
;
23 creator(const creator
<U
>&) { }
25 T
* allocate(std::size_t size
) {
26 return static_cast<T
*>(::operator new(sizeof(T
) * size
));
29 void deallocate(T
* ptr
, std::size_t) {
30 ::operator delete(ptr
);
34 template<class T
, class U
>
36 operator==(const creator
<T
>&, const creator
<U
>&)
41 template<class T
, class U
>
43 operator!=(const creator
<T
>&, const creator
<U
>&)
50 static unsigned instances
;
65 type
& operator=(const type
&);
68 unsigned type::instances
= 0;
73 boost::allocate_shared
<type
[]>(creator
<type
>(), 6);
74 BOOST_ERROR("allocate_shared did not throw");
76 BOOST_TEST(type::instances
== 0);
79 boost::allocate_shared
<type
[][2]>(creator
<type
>(), 3);
80 BOOST_ERROR("allocate_shared did not throw");
82 BOOST_TEST(type::instances
== 0);
85 boost::allocate_shared
<type
[6]>(creator
<>());
86 BOOST_ERROR("allocate_shared did not throw");
88 BOOST_TEST(type::instances
== 0);
91 boost::allocate_shared
<type
[3][2]>(creator
<>());
92 BOOST_ERROR("allocate_shared did not throw");
94 BOOST_TEST(type::instances
== 0);
97 boost::allocate_shared_noinit
<type
[]>(creator
<>(), 6);
98 BOOST_ERROR("allocate_shared_noinit did not throw");
100 BOOST_TEST(type::instances
== 0);
103 boost::allocate_shared_noinit
<type
[][2]>(creator
<>(), 3);
104 BOOST_ERROR("allocate_shared_noinit did not throw");
106 BOOST_TEST(type::instances
== 0);
109 boost::allocate_shared_noinit
<type
[6]>(creator
<>());
110 BOOST_ERROR("allocate_shared_noinit did not throw");
112 BOOST_TEST(type::instances
== 0);
115 boost::allocate_shared_noinit
<type
[3][2]>(creator
<>());
116 BOOST_ERROR("allocate_shared_noinit did not throw");
118 BOOST_TEST(type::instances
== 0);
120 return boost::report_errors();