-
Notifications
You must be signed in to change notification settings - Fork 55
Open
Description
Related to #149.
static void test_void_returning_function()
{
stdext::inplace_function<void()> f = []() { return 42; };
f = []() { return 42; };
f();
}
The above test case currently does not compile. Clang's error message is:
In file included from inplace_function_test.cpp:2:
../SG14/inplace_function.h:105:15: error: void block should not return a value
{ return (*static_cast<C*>(storage_ptr))(
^
../SG14/inplace_function.h:211:31: note: in instantiation of function template specialization 'stdext::inplace_function_detail::vtable<void>::vtable<(lambda
at inplace_function_test.cpp:412:42)>' requested here
static const vtable_t vt{inplace_function_detail::wrapper<C>{}};
^
inplace_function_test.cpp:412:42: note: in instantiation of function template specialization 'stdext::inplace_function<void (), 32,
16>::inplace_function<(lambda at inplace_function_test.cpp:412:42), (lambda at inplace_function_test.cpp:412:42), void>' requested here
stdext::inplace_function<void()> f = []() { return 42; };
^
If we fix #149, then we must make a design decision here: should this code compile (as it does with std::function
), or should it fail to compile (because returning 42
from a function with signature void(int)
usually indicates a programming error)? https://quuxplusone.github.io/blog/2019/01/06/hyper-function/ is related.
Metadata
Metadata
Assignees
Labels
No labels