From 95d4df58b39962f771885a6615efe1a682aab356 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 8 Dec 2018 20:11:35 +0900 Subject: function_traits: more tests, fix function objects/lambdas not working with some compilers A member function reference is not the same as a member function pointer. --- lib/util.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'lib/util.cpp') diff --git a/lib/util.cpp b/lib/util.cpp index 4c176fc7..5e7644a1 100644 --- a/lib/util.cpp +++ b/lib/util.cpp @@ -100,10 +100,16 @@ struct S { int mf(); }; static_assert(is_callable_v, "Test member function"); static_assert(returns(), "Test returns<> with member function"); -struct Fo { void operator()(int); }; -static_assert(function_traits::arg_number == 1, "Test function object 1"); -static_assert(is_callable_v, "Test is_callable<>"); -static_assert(std::is_same, int>(), +struct Fo { int operator()(); }; +static_assert(is_callable_v, "Test is_callable<> with function object"); +static_assert(function_traits::arg_number == 0, "Test function object"); +static_assert(std::is_same, int>::value, + "Test return type of function object"); + +struct Fo1 { void operator()(int); }; +static_assert(function_traits::arg_number == 1, "Test function object 1"); +static_assert(is_callable_v, "Test is_callable<> with function object 1"); +static_assert(std::is_same, int>(), "Test fn_arg_t defaulting to first argument"); static auto l = [] { return 1; }; -- cgit v1.2.3