为什么 std::invoke 不是 constexpr?

Why is `std::invoke` not constexpr?

不应该std::invoke be constexpr especially after constexpr lambdas in C++17吗?

是否有任何障碍可以阻止这种情况发生?

更新: P1065 将会 constexpr.


由于历史原因,保持原来的post:

来自the proposal

Although there is possibility to implement standard conforming invoke function template as a constexpr function, the proposed wording does not require such implementation. The main reason is to left it consistent with existing standard function objects, that could have such definition, like std::mem_fn, std::reference_wrapper and operator wrappers. Furthermore imposing such requirement will block the implementation of invoke that refers to std::mem_fn.

This proposal assumes that constexpr addition to the header would be applied consistently by a separate proposal.

Both constexpr and standard library based implementation are presented in Implementability section of the proposal.


相关 CWG 问题 #1581:When are constexpr member functions defined?