Why does std::forward discard constexpr-ness?
问题 Being not declared constexpr , std::forward will discard constexpr-ness for any function it forwards arguments to. Why is std::forward not declared constexpr itself so it can preserve constexpr-ness? Example: (tested with g++ snapshot-2011-02-19) #include <utility> template <typename T> constexpr int f(T x) { return -13;} template <typename T> constexpr int g(T&& x) { return f(std::forward<T>(x));} int main() { constexpr int j = f(3.5f); // next line does not compile: // error: ‘constexpr int