Paragraph 8.5.3/5 in n3797:
A reference to type “cv1 T1” is initialized by an expression of type “cv2 T2” as follows:
If the reference is an lvalue reference and the initializer expression
is an lvalue (but is not a bit-field), and “cv1 T1” is reference-compatible with “cv2 T2,” or
has a class type (i.e., T2 is a class type), where T1 is not reference-related to T2, and can be converted to an lvalue of type “cv3 T3,” where “cv1 T1” is reference-compatible with “cv3 T3” (this conversion is selected by enumerating the applicable conversion functions (13.3.1.6) and choosing the best one through overload resolution (13.3)),
...
English is not my native language, but the phrase in bold (my emphasis) seems to me to give the idea that T1
can be converted to an lvalue of type cv3 T3, which I believe is not correct. According to my understanding, T2
is the type who has to be convertible to cv3 T3, as the example:
struct B : A { operator int&(); } b;
int& ir = B();
shows.
You are not reading it correctly, this is how you should be reading it:
the initializer expression ... has a class type (i.e., T2 is a class type) ... and can be converted to an lvalue of type “cv3 T3,”
where the initializer expression refers back to:
[...]is initialized by an expression of type “cv2 T2” as follows
No, your interpretation is wrong.
T1 =
the reference that is initializedT2 =
the class typeT3 =
the lvalue that T2
can be converted toThe quoted snippet is stating that T2
(ie. the class type) can be converted to an lvalue of type T3
where T1
is reference-compatible with T3
, but that T1
is not reference-related to T2
.
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