C++相談室 part95at TECH
C++相談室 part95 - 暇つぶし2ch477:デフォルトの名無しさん
12/05/30 20:39:30.91
4.10 Pointer conversions [conv.ptr]
1 A null pointer constant is an integral constant expression (5.19) rvalue of integer type that evaluates to
zero. A null pointer constant can be converted to a pointer type; the result is the null pointer value of that
type and is distinguishable from every other value of pointer to object or pointer to function type. Two null
pointer values of the same type shall compare equal. The conversion of a null pointer constant to a pointer
to cv-qualified type is a single conversion, and not the sequence of a pointer conversion followed by a qualification
conversion (4.4).

JIS-X3014
4.10 ポインタ変換
ゼロと評価される右辺値を持つ整数型の汎整数定数式(5.19)を、空ポインタ定数と呼ぶ。空ポインタ定数
は、ポインタに変換する事ができる。その結果は、その型の空ポインタ値となる。空ポインタ値は、オブジェクト先
ポインタ型 又は 関数型ポインタ型のどんな値とも区別できる値とする。同じ型の二つの空ポインタ値は、
比較で等しくなるものでなければならない。空ポインタ定数から、cv修飾付きの型へのポインタの変換は、
単一の変換となり、ポインタ変換の後で修飾変換(4.4)を行うことはできない。

C++ではCと違い、void*を任意のポインタに代入する場合には明示的なキャストをしなくてはならなく
なったためにvoid*を使うメリットがなくなったという話

しかし単なる 0 をヌルポインタなのかdouble型の0.0なのかコンパイラが判別出来ないためにまだ問題が
残ったので、C++11ではnullptrを新設した


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch