]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/align/test/aligned_delete_test.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / align / test / aligned_delete_test.cpp
1 /*
2 Copyright 2014 Glen Joseph Fernandes
3 (glenjofe@gmail.com)
4
5 Distributed under the Boost Software License, Version 1.0.
6 (http://www.boost.org/LICENSE_1_0.txt)
7 */
8 #include <boost/align/aligned_alloc.hpp>
9 #include <boost/align/aligned_delete.hpp>
10 #include <boost/align/alignment_of.hpp>
11 #include <boost/core/lightweight_test.hpp>
12 #include <new>
13
14 class type {
15 public:
16 static unsigned count;
17
18 type() {
19 ++count;
20 }
21
22 ~type() {
23 --count;
24 }
25
26 private:
27 type(const type&);
28 type& operator=(const type&);
29 };
30
31 unsigned type::count = 0;
32
33 int main()
34 {
35 {
36 void* p = boost::alignment::aligned_alloc(1, 1);
37 char* q = ::new(p) char;
38 boost::alignment::aligned_delete()(q);
39 }
40 {
41 enum {
42 N = boost::alignment::alignment_of<type>::value
43 };
44 void* p = boost::alignment::aligned_alloc(N, sizeof(type));
45 type* q = ::new(p) type;
46 BOOST_TEST(type::count == 1);
47 boost::alignment::aligned_delete()(q);
48 BOOST_TEST(type::count == 0);
49 }
50 return boost::report_errors();
51 }