67 auto plus_one_lambda = [] (
int val) {
return ++val; };
70 gdb::function_view<int (
int)> plus_one_func_view (plus_one_lambda);
73 SELF_CHECK (plus_one_lambda (0) == 1);
74 SELF_CHECK (plus_one_lambda (1) == 2);
77 SELF_CHECK (plus_one_func_view (2) == 3);
78 SELF_CHECK (plus_one_func_view (3) == 4);
96 SELF_CHECK (func_obj (0) == 1);
126 auto plus_one_func_view2 (plus_one_func_view);
127 auto plus_one_func_view3 (plus_one_func_view2);
128 static_assert (std::is_same<
decltype (plus_one_func_view),
129 decltype (plus_one_func_view2)>
::value,
"");
130 static_assert (std::is_same<
decltype (plus_one_func_view),
131 decltype (plus_one_func_view3)>
::value,
"");
133 SELF_CHECK (plus_one_func_view3 (1) == 2);
139 constexpr gdb::function_view<int (
int)> null_func_view_1 =
nullptr;
140 constexpr auto null_func_view_2 (null_func_view_1);
146 static_assert (null_func_view_2 ==
nullptr,
"");
147 static_assert (
nullptr == null_func_view_2,
"");
148 static_assert (null_func_view_2 == NULL,
"");
149 static_assert (NULL == null_func_view_2,
"");
152 static_assert (!(null_func_view_2 !=
nullptr),
"");
153 static_assert (!(
nullptr != null_func_view_2),
"");
154 static_assert (!(null_func_view_2 != NULL),
"");
155 static_assert (!(NULL != null_func_view_2),
"");
158 static_assert (!null_func_view_2,
"");
161 constexpr gdb::function_view<int (
int)> check_ctor_nullptr (
nullptr);
162 static_assert (!check_ctor_nullptr,
"");
166 SELF_CHECK (check_op_eq_null);
167 check_op_eq_null =
nullptr;
168 SELF_CHECK (!check_op_eq_null);
217 typedef int (*func_ptr) (int);
220 SELF_CHECK (3 ==
tmpl_func (1, gdb::make_function_view (ptr)));
221 SELF_CHECK (3 ==
tmpl_func (1, gdb::make_function_view (cptr)));
225 auto lambda = [] (
int val) ->
int {
return val + 1; };
233 SELF_CHECK (3 ==
tmpl_func (1, gdb::make_function_view (lambda)));
238 SELF_CHECK (3 ==
tmpl_func (1, gdb::make_function_view (fobj)));
241 SELF_CHECK (3 ==
tmpl_func (1, gdb::make_function_view (cfobj)));