]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/align/test/is_aligned_test.cpp
ccc8c86e00db0b788ee9f4c6cf895b613420dcaa
[ceph.git] / ceph / src / boost / libs / align / test / is_aligned_test.cpp
1 /*
2 (c) 2014-2015 Glen Joseph Fernandes
3 <glenjofe -at- gmail.com>
4
5 Distributed under the Boost Software
6 License, Version 1.0.
7 http://boost.org/LICENSE_1_0.txt
8 */
9 #include <boost/align/alignment_of.hpp>
10 #include <boost/align/is_aligned.hpp>
11 #include <boost/core/lightweight_test.hpp>
12 #include <boost/config.hpp>
13
14 template<std::size_t N>
15 struct A { };
16
17 template<class T, std::size_t N>
18 void test(T* p, A<N>)
19 {
20 BOOST_TEST(boost::alignment::is_aligned(p, N));
21 BOOST_TEST(!boost::alignment::is_aligned((char*)p + 1, N));
22 }
23
24 template<class T>
25 void test(T* p, A<1>)
26 {
27 BOOST_TEST(boost::alignment::is_aligned(p, 1));
28 }
29
30 template<class T>
31 void test()
32 {
33 T o;
34 test(&o, A<boost::alignment::alignment_of<T>::value>());
35 }
36
37 class X;
38
39 int main()
40 {
41 test<bool>();
42 test<char>();
43 test<wchar_t>();
44 #if !defined(BOOST_NO_CXX11_CHAR16_T)
45 test<char16_t>();
46 #endif
47 #if !defined(BOOST_NO_CXX11_CHAR32_T)
48 test<char32_t>();
49 #endif
50 test<short>();
51 test<int>();
52 test<long>();
53 #if !defined(BOOST_NO_LONG_LONG) && !defined(_MSC_VER)
54 test<long long>();
55 #endif
56 test<float>();
57 #if !defined(_MSC_VER)
58 test<double>();
59 test<long double>();
60 #endif
61 test<void*>();
62 test<char*>();
63 test<int*>();
64 test<X*>();
65 test<void(*)()>();
66 #if !defined(_MSC_VER)
67 test<int X::*>();
68 test<int(X::*)()>();
69 #endif
70
71 return boost::report_errors();
72 }