forked from project-arcana/clean-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunique_function.cc
More file actions
46 lines (34 loc) · 925 Bytes
/
Copy pathunique_function.cc
File metadata and controls
46 lines (34 loc) · 925 Bytes
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
#include <nexus/test.hh>
#include <clean-core/unique_function.hh>
namespace
{
struct callable_t
{
void operator()() {}
};
void void_func() {}
}
TEST("cc::unique_function")
{
cc::unique_function<int(int)> f;
CHECK(!f);
f = [](int i) { return i * 2; };
CHECK(f(7) == 14);
auto f2 = cc::move(f);
CHECK(!f);
CHECK(f2(8) == 16);
}
TEST("cc::unique_function compilation", disabled)
{
auto lambda = []() -> void {};
cc::function_ptr<void()> ptr = +[]() -> void {};
callable_t type;
cc::unique_function<void()> f_tl = type;
cc::unique_function<void()> f_tr = callable_t{};
cc::unique_function<void()> f_ll = lambda;
cc::unique_function<void()> f_lr = [type]() -> void { (void)type; };
cc::unique_function<void()> f_ptrl = ptr;
cc::unique_function<void()> f_ptrr = +[]() -> void {};
cc::unique_function<void()> f_ptrf = void_func;
CHECK(true);
}