A variable template must be declared constexpr
. A lambda cannot occur in a constant-expression, so the initialisation is not allowed, and its operator()
is not declared constexpr
, so calling it isn't allowed.
In summary, this is ill-formed in the current C++14 draft.
Note: curiously, even though a lambda-expression cannot occur in a constant-expression, it seems that the closure type of a lambda may have a constexpr
copy/move constructor.