]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/smart_ptr/test/allocate_shared_array_value_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
>&)
51 boost::shared_ptr
<int[]> result
=
52 boost::allocate_shared
<int[]>(creator
<int>(), 4, 1);
53 BOOST_TEST(result
[0] == 1);
54 BOOST_TEST(result
[1] == 1);
55 BOOST_TEST(result
[2] == 1);
56 BOOST_TEST(result
[3] == 1);
59 boost::shared_ptr
<int[4]> result
=
60 boost::allocate_shared
<int[4]>(creator
<int>(), 1);
61 BOOST_TEST(result
[0] == 1);
62 BOOST_TEST(result
[1] == 1);
63 BOOST_TEST(result
[2] == 1);
64 BOOST_TEST(result
[3] == 1);
67 boost::shared_ptr
<const int[]> result
=
68 boost::allocate_shared
<const int[]>(creator
<>(), 4, 1);
69 BOOST_TEST(result
[0] == 1);
70 BOOST_TEST(result
[1] == 1);
71 BOOST_TEST(result
[2] == 1);
72 BOOST_TEST(result
[3] == 1);
75 boost::shared_ptr
<const int[4]> result
=
76 boost::allocate_shared
<const int[4]>(creator
<>(), 1);
77 BOOST_TEST(result
[0] == 1);
78 BOOST_TEST(result
[1] == 1);
79 BOOST_TEST(result
[2] == 1);
80 BOOST_TEST(result
[3] == 1);
82 return boost::report_errors();