]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/smart_ptr/test/allocate_local_shared_arrays_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 !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
12 #include <boost/core/lightweight_test.hpp>
13 #include <boost/smart_ptr/make_local_shared.hpp>
15 template<class T
= void>
21 typedef creator
<U
> other
;
27 creator(const creator
<U
>&) { }
29 T
* allocate(std::size_t size
) {
30 return static_cast<T
*>(::operator new(sizeof(T
) * size
));
33 void deallocate(T
* ptr
, std::size_t) {
34 ::operator delete(ptr
);
38 template<class T
, class U
>
40 operator==(const creator
<T
>&, const creator
<U
>&)
45 template<class T
, class U
>
47 operator!=(const creator
<T
>&, const creator
<U
>&)
55 boost::local_shared_ptr
<int[][2]> result
=
56 boost::allocate_local_shared
<int[][2]>(creator
<int>(), 2, {0, 1});
57 BOOST_TEST(result
[0][0] == 0);
58 BOOST_TEST(result
[0][1] == 1);
59 BOOST_TEST(result
[1][0] == 0);
60 BOOST_TEST(result
[1][1] == 1);
63 boost::local_shared_ptr
<int[2][2]> result
=
64 boost::allocate_local_shared
<int[2][2]>(creator
<int>(), {0, 1});
65 BOOST_TEST(result
[0][0] == 0);
66 BOOST_TEST(result
[0][1] == 1);
67 BOOST_TEST(result
[1][0] == 0);
68 BOOST_TEST(result
[1][1] == 1);
71 boost::local_shared_ptr
<const int[][2]> result
=
72 boost::allocate_local_shared
<const int[][2]>(creator
<>(), 2, {0, 1});
73 BOOST_TEST(result
[0][0] == 0);
74 BOOST_TEST(result
[0][1] == 1);
75 BOOST_TEST(result
[1][0] == 0);
76 BOOST_TEST(result
[1][1] == 1);
79 boost::local_shared_ptr
<const int[2][2]> result
=
80 boost::allocate_local_shared
<const int[2][2]>(creator
<>(), {0, 1});
81 BOOST_TEST(result
[0][0] == 0);
82 BOOST_TEST(result
[0][1] == 1);
83 BOOST_TEST(result
[1][0] == 0);
84 BOOST_TEST(result
[1][1] == 1);
86 return boost::report_errors();