forked from akrzemi1/Optional
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_type_traits.cpp
66 lines (49 loc) · 1.67 KB
/
test_type_traits.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (C) 2011 - 2012 Andrzej Krzemienski.
//
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#if (defined __clang__)
namespace std { class type_info; }
#endif
# include "optional.hpp"
namespace std { namespace experimental {
struct Val
{
Val(){}
Val( Val const & ){}
Val( Val && ) noexcept {}
Val & operator=( Val const & ) = delete;
Val & operator=( Val && ) noexcept = delete;
};
struct Safe
{
Safe(){}
Safe( Safe const & ){}
Safe( Safe && ) noexcept {}
Safe & operator=( Safe const & ){ return *this; }
Safe & operator=( Safe && ) noexcept { return *this; }
};
struct Unsafe
{
Unsafe(){}
Unsafe( Unsafe const & ){}
Unsafe( Unsafe && ){}
Unsafe & operator=( Unsafe const & ){ return *this; }
Unsafe & operator=( Unsafe && ) { return *this; }
};
struct VoidNothrowBoth
{
VoidNothrowBoth(VoidNothrowBoth&&) noexcept(true) {};
void operator=(VoidNothrowBoth&&) noexcept(true) {}; // note void return type
};
static_assert(is_nothrow_move_constructible<Safe>::value, "WTF!");
static_assert(!is_nothrow_move_constructible<Unsafe>::value, "WTF!");
static_assert(is_assignable<Safe&, Safe&&>::value, "WTF!");
static_assert(!is_assignable<Val&, Val&&>::value, "WTF!");
static_assert(is_nothrow_move_assignable<Safe>::value, "WTF!");
static_assert(!is_nothrow_move_assignable<Unsafe>::value, "WTF!");
static_assert(is_nothrow_move_constructible<VoidNothrowBoth>::value, "WTF!");
static_assert(is_nothrow_move_assignable<VoidNothrowBoth>::value, "WTF!");
}} // namespace std::experimental
int main() { }