is_standard_layout.pass.cpp revision 933afa9761c1c1f916161278a99284d50a594939
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// is_standard_layout
13
14#include <type_traits>
15
16template <class T>
17void test_is_standard_layout()
18{
19    static_assert( std::is_standard_layout<T>::value, "");
20    static_assert( std::is_standard_layout<const T>::value, "");
21    static_assert( std::is_standard_layout<volatile T>::value, "");
22    static_assert( std::is_standard_layout<const volatile T>::value, "");
23}
24
25template <class T>
26void test_is_not_standard_layout()
27{
28    static_assert(!std::is_standard_layout<T>::value, "");
29    static_assert(!std::is_standard_layout<const T>::value, "");
30    static_assert(!std::is_standard_layout<volatile T>::value, "");
31    static_assert(!std::is_standard_layout<const volatile T>::value, "");
32}
33
34template <class T1, class T2>
35struct pair
36{
37    T1 first;
38    T2 second;
39};
40
41int main()
42{
43    test_is_standard_layout<int> ();
44    test_is_standard_layout<int[3]> ();
45    test_is_standard_layout<pair<int, double> > ();
46
47    test_is_not_standard_layout<int&> ();
48}
49