int main(){
decltype(auto)&& a = 100;
}
The above code, an error in the GCC and Clang.
int main(){
decltype(int)&& a = 100;
}
This code correct.
In N4296,
In the § 8.3.2/6
If a typedef (7.1.3), a type template-parameter (14.3.1), or a decltype-specifier (7.1.6.2) denotes a type TR that is a reference to a type T, an attempt to create the type “lvalue reference to cv TR” creates the type “lvalue reference to T”, while an attempt to create the type “rvalue reference to cv TR” creates the type TR.
decltype-specifier in § 7.1.6.2
decltype-specifier:
decltype ( expression )
decltype ( auto )
I think § 8.3.2/6 is a problem with the wording.
Why reference to decltype(auto) is not allowed. Please tell me the wording of the relevant standard. Sorry in poor English. Thank you.