]> git.proxmox.com Git - ceph.git/blame - 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
CommitLineData
7c673cae 1/*
b32b8144
FG
2Copyright 2014-2015 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/alignment_of.hpp>
9#include <boost/align/is_aligned.hpp>
10#include <boost/core/lightweight_test.hpp>
11#include <boost/config.hpp>
12
13template<std::size_t N>
14struct A { };
15
b32b8144
FG
16template<std::size_t N>
17void test(char* p, A<N>)
7c673cae
FG
18{
19 BOOST_TEST(boost::alignment::is_aligned(p, N));
b32b8144 20 BOOST_TEST(!boost::alignment::is_aligned(p + 1, N));
7c673cae
FG
21}
22
b32b8144 23void test(char* p, A<1>)
7c673cae
FG
24{
25 BOOST_TEST(boost::alignment::is_aligned(p, 1));
26}
27
28template<class T>
29void test()
30{
31 T o;
b32b8144
FG
32 test(reinterpret_cast<char*>(&o),
33 A<boost::alignment::alignment_of<T>::value>());
7c673cae
FG
34}
35
36class X;
37
38int 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>();
b32b8144 56#if !defined(BOOST_MSVC)
7c673cae
FG
57 test<double>();
58 test<long double>();
59#endif
60 test<void*>();
61 test<char*>();
62 test<int*>();
63 test<X*>();
64 test<void(*)()>();
b32b8144 65#if !defined(BOOST_MSVC)
7c673cae
FG
66 test<int X::*>();
67 test<int(X::*)()>();
68#endif
69
70 return boost::report_errors();
71}