]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/align/test/is_aligned_test.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / align / test / is_aligned_test.cpp
1 /*
2 Copyright 2014-2015 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/alignment_of.hpp>
9 #include <boost/align/is_aligned.hpp>
10 #include <boost/core/lightweight_test.hpp>
11 #include <boost/config.hpp>
12
13 template<std::size_t N>
14 struct A { };
15
16 template<std::size_t N>
17 void test(char* p, A<N>)
18 {
19 BOOST_TEST(boost::alignment::is_aligned(p, N));
20 BOOST_TEST(!boost::alignment::is_aligned(p + 1, N));
21 }
22
23 void test(char* p, A<1>)
24 {
25 BOOST_TEST(boost::alignment::is_aligned(p, 1));
26 }
27
28 template<class T>
29 void test()
30 {
31 T o;
32 test(reinterpret_cast<char*>(&o),
33 A<boost::alignment::alignment_of<T>::value>());
34 }
35
36 class X;
37
38 int main()
39 {
40 test<bool>();
41 test<char>();
42 test<wchar_t>();
43 #if !defined(BOOST_NO_CXX11_CHAR16_T)
44 test<char16_t>();
45 #endif
46 #if !defined(BOOST_NO_CXX11_CHAR32_T)
47 test<char32_t>();
48 #endif
49 test<short>();
50 test<int>();
51 test<long>();
52 #if !defined(BOOST_NO_LONG_LONG) && !defined(_MSC_VER)
53 test<long long>();
54 #endif
55 test<float>();
56 #if !defined(BOOST_MSVC)
57 test<double>();
58 test<long double>();
59 #endif
60 test<void*>();
61 test<char*>();
62 test<int*>();
63 test<X*>();
64 test<void(*)()>();
65 #if !defined(BOOST_MSVC)
66 test<int X::*>();
67 test<int(X::*)()>();
68 #endif
69
70 return boost::report_errors();
71 }