]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/smart_ptr/test/allocate_local_shared_array_value_test.cpp
2 Copyright 2017 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_NO_CXX11_RVALUE_REFERENCES) && \
10 !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
11 #include <boost/core/lightweight_test.hpp>
12 #include <boost/smart_ptr/make_local_shared.hpp>
14 template<class T
= void>
20 typedef creator
<U
> other
;
26 creator(const creator
<U
>&) { }
28 T
* allocate(std::size_t size
) {
29 return static_cast<T
*>(::operator new(sizeof(T
) * size
));
32 void deallocate(T
* ptr
, std::size_t) {
33 ::operator delete(ptr
);
37 template<class T
, class U
>
39 operator==(const creator
<T
>&, const creator
<U
>&)
44 template<class T
, class U
>
46 operator!=(const creator
<T
>&, const creator
<U
>&)
54 boost::local_shared_ptr
<int[]> result
=
55 boost::allocate_local_shared
<int[]>(creator
<int>(), 4, 1);
56 BOOST_TEST(result
[0] == 1);
57 BOOST_TEST(result
[1] == 1);
58 BOOST_TEST(result
[2] == 1);
59 BOOST_TEST(result
[3] == 1);
62 boost::local_shared_ptr
<int[4]> result
=
63 boost::allocate_local_shared
<int[4]>(creator
<int>(), 1);
64 BOOST_TEST(result
[0] == 1);
65 BOOST_TEST(result
[1] == 1);
66 BOOST_TEST(result
[2] == 1);
67 BOOST_TEST(result
[3] == 1);
70 boost::local_shared_ptr
<const int[]> result
=
71 boost::allocate_local_shared
<const int[]>(creator
<>(), 4, 1);
72 BOOST_TEST(result
[0] == 1);
73 BOOST_TEST(result
[1] == 1);
74 BOOST_TEST(result
[2] == 1);
75 BOOST_TEST(result
[3] == 1);
78 boost::local_shared_ptr
<const int[4]> result
=
79 boost::allocate_local_shared
<const int[4]>(creator
<>(), 1);
80 BOOST_TEST(result
[0] == 1);
81 BOOST_TEST(result
[1] == 1);
82 BOOST_TEST(result
[2] == 1);
83 BOOST_TEST(result
[3] == 1);
85 return boost::report_errors();