Информация об изменениях

Сообщение Re[37]: Зачем плюс? от 29.11.2018 17:59

Изменено 29.11.2018 18:05 N. I.

Re[37]: Зачем плюс?
σ:

σ>Но вообще в этой инициазизации выражение попадает под lvalue-to-rvalue conversion. Смотрим, что написано про него https://timsong-cpp.github.io/cppwp/n4659/conv.lval#3

σ>The result of the conversion is determined according to the following rules:
σ>… (тут всё не подходит)
σ>(3.4) — Otherwise, the value contained in the object indicated by the glvalue is the prvalue result.

σ>lvalue *reinterpret_cast<char*>(&i) у нас indicate the int object — i.


Но значение этого lvalue интерпретируется согласно правилу, которое ты уже цитировал: "For other objects, the interpretation of the values found therein is determined by the type of the expressions ([expr.compound]) used to access them" из http://eel.is/c++draft/intro.object#1

Только вот если к char * приводится указатель на полиморфный объект, то де-юре это правило не работает, хотя де-факто должно
Re[37]: Зачем плюс?
σ:

σ>Но вообще в этой инициазизации выражение попадает под lvalue-to-rvalue conversion. Смотрим, что написано про него https://timsong-cpp.github.io/cppwp/n4659/conv.lval#3

σ>The result of the conversion is determined according to the following rules:
σ>… (тут всё не подходит)
σ>(3.4) — Otherwise, the value contained in the object indicated by the glvalue is the prvalue result.

σ>lvalue *reinterpret_cast<char*>(&i) у нас indicate the int object — i.


Но значение этого lvalue интерпретируется согласно правилу, которое ты уже цитировал: "For other objects, the interpretation of the values found therein is determined by the type of the expressions ([expr.compound]) used to access them" из http://eel.is/c++draft/intro.object#1

Только вот если через lvalue типа char мы пытаемся получить значение какого-нибудь полиморфного объекта, то де-юре это правило не работает, хотя де-факто должно