I looked in the standard for a definition of reference type but I could not find any. A naive interpretation of the reference type as the type of objects such as int & fails because according to the standard [basic.types] 10.3:
A type is a literal type if it is: […] a reference type
But the following static assert does not compile (in MSVC2015RC):
static_assert( ::std::is_literal_type< ::std::wstring & >::value, "Nope" );
What is the definition of a reference type?
The C++11 Standard defines references in §8.3.2 [dcl.ref]:
1 In a declaration
T DwhereDhas either of the forms
& attribute-specifier-seqopt D1
&& attribute-specifier-seqopt D1
and the type of the identifier in the declaration
T D1is “derived-declarator-type-list T,” then the type of the identifier ofDis “derived-declarator-type-list reference toT.” The optional attribute-specifier-seq appertains to the reference type. Cv-qualified references are ill-formed except when the cv-qualifiers are introduced through the use of a typedef (7.1.3) or of a template type argument (14.3), in which case the cv-qualifiers are ignored. [...]2 A reference type that is declared using & is called an lvalue reference, and a reference type that is declared using && is called an rvalue reference. Lvalue references and rvalue references are distinct types. Except where explicitly noted, they are semantically equivalent and commonly referred to as references.
Simply speaking, reference types are types declared as references to other types. There's much more to say about their behavior though.
Compiles just fine, in both GCC and Clang, as it should. Your compiler has probably a bugged implementation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With