is_destructible.pass.cpp revision 80e19ac90f90c5f2aef3d8a6a74b3ffd342ecd0e
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_destructible
13
14#include <type_traits>
15
16template <class T>
17void test_is_destructible()
18{
19    static_assert( std::is_destructible<T>::value, "");
20    static_assert( std::is_destructible<const T>::value, "");
21    static_assert( std::is_destructible<volatile T>::value, "");
22    static_assert( std::is_destructible<const volatile T>::value, "");
23}
24
25template <class T>
26void test_is_not_destructible()
27{
28    static_assert(!std::is_destructible<T>::value, "");
29    static_assert(!std::is_destructible<const T>::value, "");
30    static_assert(!std::is_destructible<volatile T>::value, "");
31    static_assert(!std::is_destructible<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
55struct A
56{
57    ~A();
58};
59
60int main()
61{
62    test_is_destructible<A>();
63    test_is_destructible<int&>();
64    test_is_destructible<Union>();
65    test_is_destructible<Empty>();
66    test_is_destructible<int>();
67    test_is_destructible<double>();
68    test_is_destructible<int*>();
69    test_is_destructible<const int*>();
70    test_is_destructible<char[3]>();
71    test_is_destructible<bit_zero>();
72    test_is_destructible<int[3]>();
73
74    test_is_not_destructible<int[]>();
75    test_is_not_destructible<void>();
76    test_is_not_destructible<Abstract>();
77#if __has_feature(cxx_access_control_sfinae)
78    test_is_not_destructible<NotEmpty>();
79#endif
80}
81