The question Lambda expressions as class template parameters asks about the possibility of using lambda expressions as class template parameters.
The answer to the question was no. However, it was about C++11.
Has the situation changed in the new standard, C++14?
No the situation in C++14 has not changed at all and in fact the language in section
5.1.2
Lambda expressions paragraph 2 has been tightened from:to:
Defect report 1607. Lambdas in template parameters lead to this change.
The defect report only obliquely deals with the rationale for disallowing this but we can find a very detailed explanation for why this is disallowed in Rationale for lambda-expressions not being allowed in unevaluated contexts. The reasons boil down to:
SFINAE
Given the rationale for this restriction it seems unlikely to change.
A Lambda expression shall still not appear in an unevaluated operand - the same quote as the one in Xeo's Post also exists in the latest publicly available draft N3797, in the exact same place.
However, every closure type has a deleted default constructor (N3797, §5.1.2/20):
So, for portabiliby and standard conformance (and probably for the code to work on reasonable compilers), you would need to pass a closure object to the constructor of the instantiated class to copy from. But to pass a closure object of the same type as the template argument of that specialization you have to define it first anyway:
There isn't any legal way to create a single object of the closure type of the first lambda. Therefore, even if said rule was to be removed, you couldn't create a single instance of
my_map_type
. Similar problems occur with other "closure type as template argument" scenarios.