What are the type conversion rules for parameters and return values of lambdas?
I was recently surprised by the fact that lambdas can be assigned to std::functions with slightly different signatures. Slightly different meaning that return values of the lambda might be ignored when...
View ArticleAnswer by ecatmur for What are the type conversion rules for parameters and...
You can assign a lambda to a function object of type std::function<R(ArgTypes...)> when the lambda is Lvalue-Callable for that signature. In turn, Lvalue-Callable is defined in terms of the...
View ArticleAnswer by Andrew for What are the type conversion rules for parameters and...
The assignment operator is defined to have the effect:function(std::forward<F>(f)).swap(*this);(14882:2011 20.8.11.2.1 par. 18)The constructor that this references,template <class F>...
View ArticleAnswer by Arunmu for What are the type conversion rules for parameters and...
Just adding to @ecatmur answer, g++/libstd++ just chose to ignore the return value of the callable, it's just as normal as one would do to ignore return value in regular code:static void_M_invoke(const...
View ArticleAnswer by Jonathan Wakely for What are the type conversion rules for...
the conversion from a reference to a value looks strange to meWhy?Does this look strange too?int foo(int i) { return i; }void bar(const int& ir) { foo(ir); }This is exactly the same. A function...
View Article