blob: f2a8c23246b184932dd98db1bbfafd5a5e340150 [file] [log] [blame]
Howard Hinnantc52f43e2010-08-22 00:59:46 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantc52f43e2010-08-22 00:59:46 +00007//
8//===----------------------------------------------------------------------===//
9
10// type_traits
11
12// is_abstract
13
14#include <type_traits>
15
16template <class T>
17void test_is_abstract()
18{
19 static_assert( std::is_abstract<T>::value, "");
20 static_assert( std::is_abstract<const T>::value, "");
21 static_assert( std::is_abstract<volatile T>::value, "");
22 static_assert( std::is_abstract<const volatile T>::value, "");
23}
24
25template <class T>
26void test_is_not_abstract()
27{
28 static_assert(!std::is_abstract<T>::value, "");
29 static_assert(!std::is_abstract<const T>::value, "");
30 static_assert(!std::is_abstract<volatile T>::value, "");
31 static_assert(!std::is_abstract<const volatile T>::value, "");
32}
33
34class Empty
35{
36};
37
38class NotEmpty
39{
40 virtual ~NotEmpty();
41};
42
43union Union {};
44
45struct bit_zero
46{
47 int : 0;
48};
49
50class Abstract
51{
52 virtual ~Abstract() = 0;
53};
54
55int main()
56{
57 test_is_not_abstract<void>();
58 test_is_not_abstract<int&>();
59 test_is_not_abstract<int>();
60 test_is_not_abstract<double>();
61 test_is_not_abstract<int*>();
62 test_is_not_abstract<const int*>();
63 test_is_not_abstract<char[3]>();
Marshall Clowe33e03e2014-09-02 16:19:38 +000064 test_is_not_abstract<char[]>();
Howard Hinnantc52f43e2010-08-22 00:59:46 +000065 test_is_not_abstract<Union>();
66 test_is_not_abstract<Empty>();
67 test_is_not_abstract<bit_zero>();
68 test_is_not_abstract<NotEmpty>();
69
70 test_is_abstract<Abstract>();
71}