#include <set>
#include <functional>
int main()
{
// sizeof( [] ( int v ) { return v ; } ) ; // error: expression is in unevaluated context
// using x = decltype( [] ( int v ) { return v ; } ) ; // error: expression is in unevaluated context)
auto lambda = [] ( int v ) { return v ; } ;
sizeof(lambda) ; // ok, expression has been evaluated
using y = decltype( lambda ) ; // ok, expression has been evaluated
// y yy ; // error: a closure type has no default constructor (deleted)
auto fun = [] ( int x, int y ) { return x%100 < y%100 ; } ;
// std::set< int, decltype(fun) > set_one ; // error: no default constructor
std::set< int, decltype(fun) > set_one(fun) ; // fine
// recommended
std::set< int, std::function< bool(int,int) > > set_two(
[] ( int x, int y ) { return x>y ; } ) ; // fine
}
> The sizeof operator does not evaluate expressions.
Yes, it does not. Which is why I used the the present perfect non-progressive tense "has been evaluated" (to indicate a past action that has an influence on the present).
Perhaps it would have made things clearer if the past perfect non-progressive tense was used instead, and if it was clarified that the expression being discussed is the lambda expression. ("the lambda expression had been evaluated")