blob: d843803cf21da4b4d03a754478890f123b9f8c27 [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
Howard Hinnant1468b662010-11-19 22:17:28 +000012// is_nothrow_copy_assignable
Howard Hinnantc52f43e2010-08-22 00:59:46 +000013
14#include <type_traits>
15
Marshall Clow933afa92013-07-04 00:10:01 +000016template <class T>
Howard Hinnantc52f43e2010-08-22 00:59:46 +000017void test_has_nothrow_assign()
18{
Marshall Clow933afa92013-07-04 00:10:01 +000019 static_assert( std::is_nothrow_copy_assignable<T>::value, "");
20}
21
22template <class T>
23void test_has_not_nothrow_assign()
24{
25 static_assert(!std::is_nothrow_copy_assignable<T>::value, "");
Howard Hinnantc52f43e2010-08-22 00:59:46 +000026}
27
28class Empty
29{
30};
31
Howard Hinnant27031112010-09-08 16:39:18 +000032struct NotEmpty
Howard Hinnantc52f43e2010-08-22 00:59:46 +000033{
34 virtual ~NotEmpty();
35};
36
37union Union {};
38
39struct bit_zero
40{
41 int : 0;
42};
43
Howard Hinnantc52f43e2010-08-22 00:59:46 +000044struct A
45{
46 A& operator=(const A&);
47};
48
49int main()
50{
Marshall Clow933afa92013-07-04 00:10:01 +000051 test_has_nothrow_assign<int&>();
52 test_has_nothrow_assign<Union>();
53 test_has_nothrow_assign<Empty>();
54 test_has_nothrow_assign<int>();
55 test_has_nothrow_assign<double>();
56 test_has_nothrow_assign<int*>();
57 test_has_nothrow_assign<const int*>();
58 test_has_nothrow_assign<NotEmpty>();
59 test_has_nothrow_assign<bit_zero>();
Howard Hinnantc52f43e2010-08-22 00:59:46 +000060
Marshall Clow933afa92013-07-04 00:10:01 +000061 test_has_not_nothrow_assign<const int>();
62 test_has_not_nothrow_assign<void>();
63 test_has_not_nothrow_assign<A>();
64
Howard Hinnantc52f43e2010-08-22 00:59:46 +000065}