C++相談室 part109
■ このスレッドは過去ログ倉庫に格納されています
0672デフォルトの名無しさん
2014/01/09(木) 00:47:26.295.2.9 [expr.static.cast] p1
> The result of the expression static_cast<T>(v) is the result of
> converting the expression v to type T. If T is an lvalue reference type
> or an rvalue reference to function type, the result is an lvalue; if T
> is an rvalue reference to object type, the result is an xvalue;
> otherwise, the result is a prvalue.
5.2.9 [expr.static.cast] p4
> ... an expression e can be explicitly converted to a type T using a
> static_cast of the form static_cast<T>(e) if the declaration T t(e); is
> well-formed, for some invented temporary variable t (8.5). The effect of
> such an explicit conversion is the same as performing the declaration
> and initialization and then using the temporary variable as the result
> of the conversion. ...
ってことで int a = 10; に対して static_cast<int>(a) すると
int x(a); として初期化したような一時オブジェクト(つまりコピー)が作られ、それが
prvalue として得られる。
■ このスレッドは過去ログ倉庫に格納されています