alignment_of.pass.cpp revision 091f2ab44f35b044a14359c3dc794d3688ee074f
1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// type_traits
11
12// alignment_of
13
14#include <type_traits>
15
16template <class T, unsigned A>
17void test_alignment_of()
18{
19    static_assert( std::alignment_of<T>::value == A, "");
20    static_assert( std::alignment_of<const T>::value == A, "");
21    static_assert( std::alignment_of<volatile T>::value == A, "");
22    static_assert( std::alignment_of<const volatile T>::value == A, "");
23}
24
25class Class
26{
27public:
28    ~Class();
29};
30
31int main()
32{
33    test_alignment_of<int&, sizeof(long) == 4 ? 4 : 8>();
34    test_alignment_of<Class, 1>();
35    test_alignment_of<int*, sizeof(long) == 4 ? 4 : 8>();
36    test_alignment_of<const int*, sizeof(long) == 4 ? 4 : 8>();
37    test_alignment_of<char[3], 1>();
38    test_alignment_of<int, 4>();
39    test_alignment_of<double, sizeof(long) == 4 ? 4 : 8>();
40    test_alignment_of<bool, 1>();
41    test_alignment_of<unsigned, 4>();
42}
43