Why is `std :: invoke` not constexpr?

Shouldn't std :: invoke be constexpr especially after constexpr lambdas in c ++ 17 ?

Are there any obstacles that could prevent this?

+4
c ++ invoke std constexpr c ++ 17
source share
1 answer

From the offer :

Although it is possible to implement the standard invoke matching pattern as a constexpr function, the proposed formulation does not require such an implementation. The main reason is to leave it in accordance with existing objects of standard functions that may have such a definition, for example std :: mem_fn, std :: reference_wrapper and operator shells. In addition, the imposition of such a requirement blocks the implementation of a call that refers to std :: mem_fn.

This sentence assumes that adding constexpr to the header will be applied sequentially in a separate sentence.

Both options for implementing constexpr and the standard library are presented in the "Realism" section of the proposal.


CWG # 1581 Related Problem: When are constexpr member functions defined? .

+8
source share

All Articles