]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/smart_ptr/test/allocate_unique_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 >= 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
>&)
55 static unsigned instances
;
70 type
& operator=(const type
&);
73 unsigned type::instances
= 0;
78 boost::allocate_unique
<type
>(creator
<type
>());
79 BOOST_ERROR("allocate_unique did not throw");
81 BOOST_TEST(type::instances
== 0);
84 boost::allocate_unique
<const type
>(creator
<>());
85 BOOST_ERROR("allocate_unique did not throw");
87 BOOST_TEST(type::instances
== 0);
89 return boost::report_errors();