Re[10]: ссылка на локальный вектор
От: uzhas Ниоткуда  
Дата: 16.05.16 11:19
Оценка:
Здравствуйте, uzhas, Вы писали:

U>читаем внимательнее выделенное: different but convertible type


кстати, вот в этом примере не должен создаваться "temporary object":
struct A {};
struct B : A {};
B b;
const A& a = b;

хотя тут есть "different but convertible type"
скорее всего эта цитата на сайте не очень точна и может ввести в заблуждение
рекомендую обратиться к Стандарту за более точной формулировкой:
начни отсюда, дальше по главам прыгать надо

12.2 Temporary objects [class.temporary]
1 Temporaries of class type are created in various contexts: binding a reference to a prvalue (8.5.3), returning
a prvalue (6.6.3), a conversion that creates a prvalue (4.1, 5.2.9, 5.2.11, 5.4), throwing an exception (15.1),
and in some initializations (8.5). [ Note: The lifetime of exception objects is described in 15.1. —end note ]
Even when the creation of the temporary object is unevaluated (Clause 5) or otherwise avoided (12.8), all
the semantic restrictions shall be respected as if the temporary object had been created and later destroyed.
[ Note: This includes accessibility (11) and whether it is deleted, for the constructor selected and for the
destructor. However, in the special case of a function call used as the operand of a decltype-specifier (5.2.2),
no temporary is introduced, so the foregoing does not apply to the prvalue of any such function call. —end
note ]

 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.