-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathconcepts_test.cpp
54 lines (40 loc) · 1.18 KB
/
concepts_test.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
#include "fixed_containers/concepts.hpp"
#include "fixed_containers/assert_or_abort.hpp"
#include <functional>
namespace fixed_containers
{
static_assert(!IsTransparent<std::less<int>>);
static_assert(IsTransparent<std::less<>>);
struct MockConstexprDefaultConstructible
{
constexpr MockConstexprDefaultConstructible() { assert_or_abort(true); }
};
struct MockNonConstexprDefaultConstructible
{
MockNonConstexprDefaultConstructible() { assert_or_abort(true); }
};
static_assert(ConstexprDefaultConstructible<MockConstexprDefaultConstructible>);
static_assert(NotConstexprDefaultConstructible<MockNonConstexprDefaultConstructible>);
struct MockStructuralType
{
constexpr MockStructuralType()
: a()
{
}
int a;
};
struct MockNonStructuralType
{
constexpr MockNonStructuralType()
: a()
{
}
int getter_so_field_a_is_used() const { return a; }
private:
int a;
};
static_assert(ConstexprDefaultConstructible<MockStructuralType>);
static_assert(IsStructuralType<MockStructuralType>);
static_assert(ConstexprDefaultConstructible<MockNonStructuralType>);
static_assert(IsNotStructuralType<MockNonStructuralType>);
} // namespace fixed_containers