]> git.proxmox.com Git - ceph.git/blame - 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
CommitLineData
7c673cae 1/*
b32b8144
FG
2Copyright 2014 Glen Joseph Fernandes
3(glenjofe@gmail.com)
7c673cae 4
b32b8144
FG
5Distributed under the Boost Software License, Version 1.0.
6(http://www.boost.org/LICENSE_1_0.txt)
7c673cae
FG
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
7c673cae
FG
14class type {
15public:
b32b8144
FG
16 static unsigned count;
17
18 type() {
19 ++count;
7c673cae 20 }
b32b8144 21
7c673cae 22 ~type() {
b32b8144 23 --count;
7c673cae 24 }
b32b8144 25
7c673cae 26private:
b32b8144
FG
27 type(const type&);
28 type& operator=(const type&);
7c673cae
FG
29};
30
b32b8144 31unsigned type::count = 0;
7c673cae
FG
32
33int main()
34{
b32b8144
FG
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 }
7c673cae
FG
50 return boost::report_errors();
51}