According to n4487 and other c++17 references, there will be new lambda function specifier - constexpr , which if present "explicitly specifies that the function call operator is a constexpr function.". I understand the motivation about constant expressions in lambdas. What is interesting for me is point 4 of proposal which states:
4) If the
constexprspecifier is omitted within the lambda-declarator, the function call operator (or template) isconstexprif it would satisfy the requirements of aconstexprfunction.
This leads me to two questions:
- Why do we need
constexprspecifier? Looks like that whether the lambda call operator will beconstexpror not depends only on the fact will it "satisfy the requirements of aconstexprfunction", but not fromconstexprspecifier presence. - If it is acceptable to have
constexprlambda by default, why isn't it proposed for other types of functions as well - for example global functions? What will be the impact if compiler starts to treat all functions which cover requirements asconstexpr?