For the following code, all but the last assertion passes:
template
constexpr void assert_static_cast_identity() {
using T_cast = decltype(
This is hard-coded in the definition of static_cast:
[expr.static.cast] (emphasis mine)
1 The result of the expression
static_cast<T>(v)is the result of converting the expressionvto typeT. IfTis an lvalue reference type or an rvalue reference to function type, the result is an lvalue; ifTis an rvalue reference to object type, the result is an xvalue; otherwise, the result is a prvalue. Thestatic_castoperator shall not cast away constness.
decltype respects the value category of its operand, and produces an lvalue reference for lvalue expressions.
The reasoning may be due to function names themselves always being lvalues, and so an rvalue of a function type cannot appear "in the wild". As such, casting to that type probably makes little sense.