5

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.

Shafik Yaghmour
  • 154,301
  • 39
  • 440
  • 740
Wake up Brazil
  • 3,421
  • 12
  • 19
  • `N3485` is the last *C++11* draft, what you are referencing would be `C++1y`, see [Where do I find the current C or C++ standard documents?](http://stackoverflow.com/questions/81656/where-do-i-find-the-current-c-or-c-standard-documents/4653479#4653479) – Shafik Yaghmour Feb 20 '14 at 18:39
  • Since you quote `N3797` this applies to *C++1y* as well. The wording is nearly identical in `N3485`. – Shafik Yaghmour Feb 21 '14 at 01:47

2 Answers2

4

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

Shafik Yaghmour
  • 154,301
  • 39
  • 440
  • 740
1

No, your interpretation is wrong.

  • T1 = the reference that is initialized
  • T2 = the class type
  • T3 = the lvalue that T2 can be converted to

The 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.

David G
  • 94,763
  • 41
  • 167
  • 253
Filip Roséen - refp
  • 62,493
  • 20
  • 150
  • 196