blob: 344a8563876f2b638b489c3069c21fe0a234c8a6 (
plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
#include "testutilities.h"
#include <iostream>
#include <sigc++/signal.h>
struct MoveableStruct
{
};
namespace
{
TestUtilities* util = nullptr;
std::ostringstream result_stream;
struct foo
{
void operator()(MoveableStruct&& /* x */) { result_stream << "foo(MoveableStruct&&)"; }
};
struct A
{
void foo(MoveableStruct&&) { result_stream << "A::foo(MoveableStruct&&)"; }
};
void
boo(MoveableStruct&&)
{
result_stream << "boo(MoveableStruct&&)";
}
} // end anonymous namespace
void
test_signal()
{
sigc::signal<void(MoveableStruct &&)> signal;
foo f;
signal.connect(f);
MoveableStruct x;
signal(std::move(x));
util->check_result(result_stream, "foo(MoveableStruct&&)");
}
void
test_slot()
{
sigc::slot<void(MoveableStruct &&)> slot;
foo f;
slot = f;
MoveableStruct x;
slot(std::move(x));
util->check_result(result_stream, "foo(MoveableStruct&&)");
}
void
test_mem_fun()
{
sigc::slot<void(A&, MoveableStruct &&)> slot;
A a;
slot = sigc::mem_fun(&A::foo);
MoveableStruct x;
slot(a, std::move(x));
util->check_result(result_stream, "A::foo(MoveableStruct&&)");
}
void
test_bound_mem_fun()
{
sigc::slot<void(MoveableStruct &&)> slot;
A a;
slot = sigc::mem_fun(a, &A::foo);
MoveableStruct x;
slot(std::move(x));
util->check_result(result_stream, "A::foo(MoveableStruct&&)");
}
void
test_ptr_fun()
{
sigc::slot<void(MoveableStruct &&)> slot;
slot = sigc::ptr_fun(&boo);
MoveableStruct x;
slot(std::move(x));
util->check_result(result_stream, "boo(MoveableStruct&&)");
}
int
main(int argc, char* argv[])
{
util = TestUtilities::get_instance();
if (!util->check_command_args(argc, argv))
return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
test_signal();
test_slot();
test_bound_mem_fun();
test_mem_fun();
test_ptr_fun();
return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
} // end main()
|