名前空間
変種
操作

Implicit conversions

提供: cppreference.com
< cpp‎ | language

 
 
C + +言語
一般的なトピック
Original:
General topics
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
フロー制御
Original:
Flow control
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
条件付き実行文
Original:
Conditional execution statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
繰り返し文
Original:
Iteration statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
文をジャンプします
Original:
Jump statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
機能します
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
関数の宣言
ラムダ関数の宣言
関数テンプレート
の歴史。インライン指定
例外仕様 (廃止予定)
noexcept指定子 (C++11)
例外
Original:
Exceptions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
名前空間
Original:
Namespaces
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
タイプ
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
decltype specifier (C++11)
指定子
Original:
Specifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
CV指定
貯蔵期間指定
constexprの指定子 (C++11)
自動指定 (C++11)
alignas指定子 (C++11)
初期化
Original:
Initialization
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
リテラル
Original:
Literals
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Original:
Expressions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
代替表現
ユーティリティ
Original:
Utilities
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
タイプ
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
typedef declaration
型の別名宣言 (C++11)
属性 (C++11)
キャストします
Original:
Casts
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
暗黙の型変換
const_cast conversion
static_cast conversion
dynamic_cast conversion
reinterpret_cast conversion
Cスタイルキャストと機能
メモリの割り当て
Original:
Memory allocation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
クラス
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
クラス固有の機能特性
Original:
Class-specific function properties
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
明示 (C++11)
静的
特殊なメンバ関数
Original:
Special member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
テンプレート
Original:
Templates
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
クラステンプレート
関数テンプレート
テンプレートの特殊化
パラメーターパック (C++11)
その他
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
インラインアセンブリ
 
暗黙的な変換はいくつかの型T1の発現は、その型を受け付けない文脈で使用されるたびに実行されますが、特定のいくつかの他のタイプのT2を受け付けています:
Original:
Implicit conversions are performed whenever an expression of some type T1 is used in context that does not accept that type, but accepts some other type T2, in particular:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • パラメータとしてT2と宣言された関数を呼び出すときに式が引数として使用されている場合.
    Original:
    When the expression is used as the argument when calling a function that is declared with T2 as parameter.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 式はT2を期待演算子のオペランドとして使用する場合
    Original:
    When the expression is used as an operand with an operator that expects T2
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • T2を返す関数でreturn文を含むタイプT2の新しいオブジェクトを初期化するとき.
    Original:
    When initializing a new object of type T2, including return statement in a function returning T2.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 式はswitch文で使用されている場合(T2整数型です)
    Original:
    When the expression is used in a switch statement (T2 is integral type)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 式はif文またはループ(T2bool)に使用される場合
    Original:
    When the expression is used in an if statement or a loop (T2 is bool)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
プログラムはT1からT2に1明白な暗黙の変換シーケンスが存在する場合にのみ、(コンパイル)整形式で.
Original:
The program is well-formed (compiles) only if there exists one unambiguous implicit conversion sequence from T1 to T2.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
暗黙の変換シーケンスがT1からT2に利用可能な各構築された後に呼び出されている関数や演算子の複数のオーバーロードがある場合、オーバーロードの解決ルールはコンパイルされる過決定.
Original:
If there are multiple overloads of the function or operator being called, after the implicit conversion sequence is built from T1 to each available T2, オーバーロードの解決 rules decide which overload is compiled.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] 変換の順序

暗黙的な変換シーケンスは、この順序で、次の要素で構成されます
Original:
Implicit conversion sequence consists of the following, in this order:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
1)
ゼロまたは1標準変換シーケンス
Original:
zero or one standard conversion sequence
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
ゼロまたは1ユーザー定義の変換
Original:
zero or one user-defined conversion
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3)
ゼロまたは1つの標準的な変換シーケンス
Original:
zero or one standard conversion sequence
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
コンストラクタに、またはユーザー定義の変換関数への引数を検討する際には、唯一つの標準変換シーケンスが許されている(そうでなければ、ユーザー定義の変換効率的に連鎖させることができます)。に1ビルトイン型から変換する場合、別の組み込み型で、唯一の標準変換シーケンスが許可されている.
Original:
When considering the argument to a constructor or to a user-defined conversion function, only one standard conversion sequence is allowed (otherwise user-defined conversions could be effectively chained). When converting from one built-in type to another built-in type, only one standard conversion sequence is allowed.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
標準変換シーケンスは、この順序で、次の要素で構成されます
Original:
A standard conversion sequence consists of the following, in this order:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
1)
ゼロまたは1左辺値変換
Original:
zero or one lvalue transformation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
ゼロまたは1数値昇格数値変換
Original:
zero or one numeric promotion or numeric conversion
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3)
ゼロまたは1資格調整
Original:
zero or one qualification adjustment
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ユーザー定義の変換は以下から成ります
Original:
A user-defined conversion consists of:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
@ * @ゼロまたは1つの非明示的な単一引数コンストラクタまたは非明示的な変換関数を呼び出します
Original:
@*@ zero or one non-explicit single-argument constructor or non-explicit conversion function call
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
表現eがあると言われて'T2宣言T2 t=e;が整形されている場合にだけ、(コンパイルすることができます)に暗黙的に変換可能な、いくつかの発明のために一時的なt。これは明示的なコンストラクタと変換関数がさらにあると考えられるでしょうT2 t(e)、異なることに注意してください.
Original:
An expression e is said to be implicitly convertible to T2 if and only if the declaration T2 t=e; is well-formed (can be compiled), for some invented temporary t. Note that this is different from T2 t(e), where explicit constructors and conversion functions would additionally be considered.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
一つの例外は、上記のルールであるタイプ(C++11およびそれ以降)が期待されている次の5つのコンテキストbool、で呼び出さ特別暗黙の型変換は以下の通りです
Original:
One exception is the above rule is the special implicit conversion invoked in the following five contexts (C++11およびそれ以降), where type bool is expected:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • ifの発現を制御し、whilefor
    Original:
    controlling expression of if, while, for
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 論理演算子!&&||
    Original:
    the logical operators !, && and ||
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 条件演算子の?:
    Original:
    the conditional operator ?:
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • static_assert
  • noexcept
宣言bool t(e);が整形されている場合はそのような文脈では、暗黙の変換シーケンスが構築されています。それは、そのようなexplicit T::operator bool() const;が考慮されるように、明示的なユーザー定義変換関数です。このような発現eがあると言われて'ブールに文脈的に転換.
Original:
in such contexts, implicit conversion sequence is built if the declaration bool t(e); is well-formed. that is, the explicit user-defined conversion function such as explicit T::operator bool() const; is considered. Such expression e is said to be contextually convertible to bool.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 左辺値変換

左辺値の引数(オブジェクトへの参照など)は右辺値(番号など)が期待されているコンテキストで使用されているときに左辺値の変換が適用されます.
Original:
Lvalue transformations are applied when lvalue argument (e.g. reference to an object) is used in context where rvalue (e.g. a number) is expected.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 右辺値への変換左辺値

任意の非機能、非配列型Tのglvalueは、暗黙的に同じタイプのprvalueに変換することができます。 Tは非クラス型の場合、この変換はまたのcv-修飾子を削除します。コンストラクタの引数として、オリジナルglvalueを使用して、型の一時オブジェクトTは、未評価のコンテキスト(sizeof演算子、typeidは、noexcept、またはdecltypeのオペランド内)に遭遇、この変換が効果的にコピー·構築しない限り、その一時オブジェクトがprvalueとして返されます。 。 glvalueが型std::nullptr_tを持っている場合、結果のprvalueはヌルポインタ定数nullptrです.
Original:
A glvalue of any non-function, non-array type T can be implicitly converted to prvalue of the same type. If T is a non-class type, this conversion also removes cv-qualifiers. Unless encountered in unevaluated context (in an operand of sizeof, typeid, noexcept, or decltype), this conversion effectively copy-constructs a temporary object of type T using the original glvalue as the constructor argument, and that temporary object is returned as a prvalue. If the glvalue has the type std::nullptr_t, the resulting prvalue is the null pointer constant nullptr.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] ポインタへの変換配列

左辺値または型の右辺値 "NTの配列"または "Tの下限未知の配列は"暗黙 "Tへのポインタ"型のprvalueに変換することができます。結果のポインタは配列の最初の要素を指す.
Original:
A lvalue or rvalue of type "array of N T" or "array of unknown bound of T" can be implicitly converted to a prvalue of type "pointer to T". The resulting pointer refers to the first element of the array.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] ポインタへの関数

関数型T​​の左辺値は、暗黙的にその関数へprvalueポインタに変換することができます。非静的メンバ関数を参照する左辺値が存在しないため、これは、非静的メンバ関数には適用されません.
Original:
An lvalue of function type T can be implicitly converted to a prvalue pointer to that function. This does not apply to non-static member functions because lvalues that refer to non-static member functions do not exist.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 数値のプロモーション

[編集] 整数の昇格

小さな整数型(例えばcharなど)のPrvalues​​はより大きな整数型(intなど)のprvalues​​に変換してもよい。特に、算術演算子は、引数としてintよりも小さいタイプを受け入れないし、汎整数拡張が自動的に適用されます。この変換は、常に値を保持..
Original:
Prvalues of small integral types (such as char) may be converted to prvalues of larger integral types (such as int). In particular, 算術演算子 do not accept types smaller than int as arguments, and integral promotions are automatically applied. This conversion always preserves the value.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
次の暗黙的な変換は、汎整数拡張のように分類されます
Original:
The following implicit conversions are classified as integral promotions:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • signed charまたはsigned shortintに変換することができます.
    Original:
    signed char or signed short can be converted to int.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • unsigned charまたはunsigned shortunsigned intに変換することができます.
    Original:
    unsigned char or unsigned short can be converted to unsigned int.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • charに変換することができますintまたはunsigned int基になる型に応じて次のsigned charまたはunsigned char(上記参照)
    Original:
    char can be converted to int or unsigned int depending on the underlying type: signed char or unsigned char (see above)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • wchar_tchar16_t、とchar32_tが彼らの全体の値の範囲を保持することができ、以下のリストから最初の型に変換することができます。intunsigned intlongunsigned longlong longunsigned long long.
    Original:
    wchar_t, char16_t, and char32_t can be converted to the first type from the following list able to hold their entire value range: int, unsigned int, long, unsigned long, long long, unsigned long long.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 基になる型が固定されていません'スコープを持たない列挙型は彼らの全体の値の範囲を保持することができ、以下のリストから最初の型に変換することができます。intunsigned intlongunsigned longlong long、またはunsigned long long。値の範囲が大きい場合、汎整数拡張は適用されません.
    Original:
    An unscoped enumeration type whose underlying type is not fixed can be converted to the first type from the following list able to hold their entire value range: int, unsigned int, long, unsigned long, long long, or unsigned long long. If the value range is greater, no integral promotions apply.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 基になる型が固定されている範囲外の列挙'タイプは、その昇格基になる型に変換することができます。 (C++11およびそれ以降)
    Original:
    An unscoped enumeration type whose underlying type is fixed can be converted to its promoted underlying type. (C++11およびそれ以降)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • それはビットフィールド全体の値の範囲を表すことができる場合、それはintにそうでなければ、ビットフィールド全体の値の範囲を表すことができる場合はビットフィールド型unsigned intに変換することができ、そうしないと、汎整数拡張は適用されません.
    Original:
    A bitfield type can be converted to int if it can represent entire value range of the bitfield, otherwise to unsigned int if it can represent entire value range of the bitfield, otherwise no integral promotions apply.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • タイプboolは値でintに変換することができfalse0true1なってなってきて.
    Original:
    The type bool can be converted to int with the value false becoming 0 and true becoming 1.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

[編集] 浮動小数点昇進

タイプfloatのprvalueはタイプdoubleのprvalueに変換することができます。値は変更されません.
Original:
A prvalue of type float can be converted to prvalue of type double. The value does not change.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 数値変換

プロモーションとは異なり、数値変換は、精度が失われる可能性があると、値を変更することがあります.
Original:
Unlike the promotions, numeric conversions may change the values, with potential loss of precision.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 整数変換

整数型またはスコープを持たない列挙型のprvalueは、他の整数型に変換することができます。変換は、汎整数拡張の下にリストされている場合は、プロモーションではなく、変換したものです.
Original:
A prvalue of an integer type or of an unscoped enumeration type can be converted to any other integer type. If the conversion is listed under integral promotions, it is a promotion and not a conversion.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • 変換先の型がunsignedである場合、結果の値はモジュロ2n
    nが変換先の型を表すために使用されるビット数での値です。 2の補数演算(C + +コンパイラで使用可能なすべてのプラットフォームで使用される)では、この変換では、変換先の型が小さいにある場合は切り捨てを除いて、no-opです.
    Original:
    If the destination type is unsigned, the resulting value is the value modulo 2n
    where n is the number of bits used to represent the destination type. In 2's complement arithmetic (used on all platforms where C++ compilers are available), this conversion is a no-op, except for the truncation if the destination type is to small.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 宛先タイプが署名されている場合、送信元の整数は、変換先の型で表現できる場合、値は変更されません。そうでなければ結果は実装定義です.
    Original:
    If the destination type is signed, the value does not change if the source integer can be represented in the destination type. Otherwise the result is implementation-defined.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • ソース·タイプがboolである場合、値falseはゼロに変換され、値trueは、宛先のタイプ(宛先タイプがintであれば、これは整数昇格ではなく、整数変換であることに注意してください)​​の値のいずれかに変換されます
    Original:
    If the source type is bool, the value false is converted to zero and the value true is converted to the value one of the destination type (note that if the destination type is int, this is an integer promotion, not an integer conversion)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 宛先タイプがboolである場合、これはブール値変換(下記参照)です
    Original:
    If the destination type is bool, this is a boolean conversion (see below)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

[編集] ポイントの変換に浮かぶ

浮動小数点型のprvalueは、他の浮動小数点型のprvalueに変換することができます。変換は、浮動小数点キャンペーンの下に表示されている場合、それは昇進ではなく変換することです.
Original:
A prvalue of an floating-point type can be converted to prvalue of any other floating-point type. If the conversion is listed under floating-point promotions, it is a promotion and not a conversion.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • ソース値が変換先の型で正確に表現することができれば、それは変わりません.
    Original:
    If the source value can be represented exactly in the destination type, it does not change.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • ソース値が変換先の型の2つの表現の値の間にある場合、結果は、これら2つの値(それは、実装定義されたもの)の一つである
    Original:
    If the source value is between two representable values of the destination type, the result is one of those two values (it is implementation-defined which one)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • それ以外の場合は、動作は未定義です.
    Original:
    Otherwise, the behavior is undefined.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

[編集] 浮動 - 整数変換

  • 浮動小数点型のprvalueは任意の整数型のprvalueに変換することができます。小数部分は、小数部分は破棄されている、切り捨てられます。値が変換先の型に収まらない場合、動作は未定義です。宛先タイプがboolである場合、これはブール値変換(下記参照)です.
    Original:
    A prvalue of floating-point type can be converted to prvalue of any integer type. The fractional part is truncated, that is, the fractional part is discarded. If the value can not fit into the destination type, the behavior is undefined. If the destination type is bool, this is a boolean conversion (see below).
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 整数またはスコープを持たない列挙型のprvalueは任意の浮動小数点型のprvalueに変換することができます。値が正しく表現できない場合、それはより高い一番下または一番近い表現可能な値が選択されるかどうかを定義した実装です。値が変換先の型に収まらない場合、動作は未定義です。ソース·タイプがboolである場合、値falseは0に変換され、値trueは1に変換されます.
    Original:
    A prvalue of integer or unscoped enumeration type can be converted to prvalue of any floating-point type. If the value can not be represented correctly, it is implementation defined whether the closest higher or the closest lower representable value will be selected. If the value can not fit into the destination type, the behavior is undefined. If the source type is bool, the value false is converted to zero, and the value true is converted to one.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

[編集] ポインタ変換

  • ヌル·ポインタ定数またはリテラルNULL'ヌルポインタを含む積分がゼロと評価された型または型std::nullptr_tのいずれprvalue、他のどのprvaluenullptr、任意のポインタ型に変換され、その結果であることができますその型のヌルポインタ値です。このような変換は、(nullポインタ変換 'として知られている変換TOT、それは数字の組み合わせとみなされ、変換を修飾していないのはされている単一の変換などのcv-修飾された型に許される).
    Original:
    The null pointer constant NULL or any other prvalue of integral type that evaluates to zero or any prvalue of type std::nullptr_t, including the null pointer literal nullptr, can be converted to any pointer type, and the result is the null pointer value of that type. Such conversion (known as 'null pointer conversion is allowed to conver tot a cv-qualified type as a single conversion, that is, it's not considered a combination of numeric and qualifying conversions).
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 任意(任意のcv-修飾)オブジェクトタイプTへprvalueポインタがにprvalueポインタ(同一のcv-修飾)voidに変換することができます。 Tは、ポイント先のオブジェクトの実行時の型でない場合、結果のポインタはほとんどの派生オブジェクトが占有するストレージの先頭を指すように調整されます。元のポインタがヌルポインタの値である場合、結果は先の型のヌルポインタ値です.
    Original:
    A prvalue pointer to any (optionally cv-qualified) object type T can be converted to a prvalue pointer to (identically cv-qualified) void. If T is not the runtime type of the pointed-to object, the resulting pointer is adjusted to point to the start of the storage occupied by the most-derived object. If the original pointer is a null pointer value, the result is a null pointer value of the destination type.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • (オプションでCV修飾)派生クラス型へprvalueポインタがそのアクセス可能な明白な(同じCV修飾名でも可)の基底クラスへのポインタをprvalueに変換することができます。変換の結果は、ポイント先のオブジェクト内で基本クラスのサブオブジェクトへのポインタです。ヌルポインタの値は、変換先の型のヌルポインタ値に変換されます.
    Original:
    A prvalue pointer to a (optionally cv-qualified) derived class type can be converted to prvalue pointer to its accessible, unambiguous (identically cv-qualified) base class. The result of the conversion is a pointer to the base class subobject within the pointed-to object. The null pointer value is converted to the null pointer value of the destination type.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

[編集] メンバへのポインタへの変換

  • nullポインタ定数NULLゼロまたはリテラル NULLポインタstd::nullptr_t、任意のメンバへのポインタ型に変換することができるなど、型nullptrのいずれprvalue、と評価された一体型タイプの他のどのprvalueそして結果はその型のヌルポインタ値です。このような変換は、(nullポインタ変換 'として知られている変換TOT、それは数字の組み合わせとみなされ、変換を修飾していないのはされている単一の変換などのcv-修飾された型に許される).
    Original:
    The null pointer constant NULL or any other prvalue of integral type that evaluates to zero or any prvalue of type std::nullptr_t, including the null pointer literal nullptr, can be converted to any pointer-to-member type, and the result is the null pointer value of that type. Such conversion (known as 'null pointer conversion is allowed to conver tot a cv-qualified type as a single conversion, that is, it's not considered a combination of numeric and qualifying conversions).
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 基底クラスTにおけるいくつかの型BのメンバーへのPrvalueポインタはその派生クラスTに同じタイプのDのメンバへのポインタをprvalueに変換することができます。 Bは、アクセスできないあいまいな、またはDのベース仮想であるかDのいくつかの中間仮想ベースのベースである場合、変換(コンパイルされません)不適格です。結果のポインタはDオブジェクトと間接参照することができ、そしてそれはそのBオブジェクトのDベースサブオブジェクト内のメンバにアクセスします。ヌルポインタの値は、変換先の型のヌルポインタ値に変換されます.
    Original:
    Prvalue pointer to member of some type T in a base class B can be converted to prvalue pointer to member of the same type T in its derived class D. If B is inaccessible, ambiguous, or virtual base of D or is a base of some intermediate virtual base of D, the conversion is ill-formed (won't compile). The resulting pointer can be dereferenced with a D object, and it will access the member within the B base subobject of that D object. The null pointer value is converted to the null pointer value of the destination type.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

[編集] ブール変換

整数型、浮動小数点型、​​スコープを持たない列挙型、ポインタ、メンバへのポインタ型のPrvalues​​は、タイプboolのprvalues​​に変換することができます.
Original:
Prvalues of integral, floating-point, unscoped enumeration, pointer, and pointer-to-member types can be converted to prvalues of type bool.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
値ゼロ(整数、浮動小数点、およびスコープを持たない列挙用)とヌルポインタとなるfalseヌルポインタからメンバへの値。他のすべての値はtrueになる.
Original:
The value zero (for integral, floating-point, and unscoped enumeration) and the null pointer and the null pointer-to-member values become false. All other values become true.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
std::nullptr_t含むタイプnullptr、のPrvalueはタイプboolのprvalueに変換することができます。結果の値はfalseです。 (C++11およびそれ以降)
Original:
Prvalue of type std::nullptr_t, including nullptr, can be converted to prvalue of type bool. The resulting value is false. (C++11およびそれ以降)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 資格変換

  • クラスTにおけるcv修飾型Xのメンバへのポインタ型のprvalueには、クラス内のより多くのCV修飾型TXのメンバへのポインタをprvalueに変換することができます.
    Original:
    A prvalue of type pointer to member of cv-qualified type T in class X can be converted to prvalue pointer to member of more cv-qualified type T in class X.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
"その他"のcv-修飾を意味します
Original:
"More" cv-qualified means that
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • '修飾されていないタイプがconstに変換することができます
    Original:
    unqualified type can be converted to const
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • '修飾されていないタイプがvolatileに変換することができます
    Original:
    unqualified type can be converted to volatile
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • '修飾されていないタイプがconst volatileに変換することができます
    Original:
    unqualified type can be converted to const volatile
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • constタイプはconst volatileに変換することができます
    Original:
    const type can be converted to const volatile
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • volatileタイプはconst volatileに変換することができます
    Original:
    volatile type can be converted to const volatile
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
マルチレベルのポインタについては、次の制限が適用されます
Original:
For multi-level pointers, the following restrictions apply:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
P1修飾ポインタへcv1
0
修飾ポインタであるマルチレベルポインタcv1
1
... cv1
n-1
修飾cv1
n
T修飾ポインタがにP1修飾ポインタへcv2
0
修飾ポインタであるマルチレベルポインタcv2
1
に変換可能である... cv2
n-1
修飾cv2
n
場合にのみにT修飾ポインタ
Original:
A multilevel pointer P1 which is cv1
0
-qualified pointer to cv1
1
-qualified pointer to ... cv1
n-1
-qualified pointer to cv1
n
-qualified T is convertible to a multilevel pointer P1 which is cv2
0
-qualified pointer to cv2
1
-qualified pointer to ... cv2
n-1
-qualified pointer to cv2
n
-qualified T only if
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • レベルの数はn両方のポインタでも同じです
    Original:
    The number of levels n is the same for both pointers
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • P1のいくつかのレベル(レベルゼロ以外)でconst資格でcv1
    k
    がある場合は、P2の同じレベルconstcv2
    k
    がある
    Original:
    If there is a const in the cv1
    k
    qualification at some level (other than level zero) of P1, there is a const in the same level cv2
    k
    of P2
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • P1のいくつかのレベルでvolatile資格でcv1
    k
    (他のレベルがゼロより)がある場合、P2の同じvolatilelevelでcv2
    k
    があります
    Original:
    If there is a volatile in the cv1
    k
    qualification at some level (other than level zero) of P1, there is a volatile in the same cv2
    k
    level of P2
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • いくつかのレベルでkCV-資格がP1間で異なっている場合やP2、その後P2までの一つ一つのレベル(レベルゼロ以外)でconstであるに違いありませんKまで:cv2
    1
    , cv2
    2
    ... cv2
    k
    .
    Original:
    If at some level k the cv-qualifications are different between P1 and P2, then there must be a const at every single level (other than level zero) of P2 up until k: cv2
    1
    , cv2
    2
    ... cv2
    k
    .
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 同じ規則がメンバーやオブジェクトやメンバへのポインタへのマルチレベル混合ポインタへのマルチレベルのポインタに適用さ.
    Original:
    Same rules apply to multi-level pointers to members and multi-level mixed pointers to objects and pointers to members.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • レベルゼロは、非マルチレベルの資格変換の規則によってアドレス指定される.
    Original:
    Level zero is addressed by the rules for non-multilevel qualification conversions.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
特に、これはT**からconst T**への変換を禁止しているが、const T* const*への変換は許可されている.
Original:
In particular, this forbids the conversion from T** to const T**, but conversion to const T* const* is allowed.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 安全なブール値問題

C言語での明示的な変換関数が導入されるまで+ 11、ブーリアンコンテキストで使用可能であるべきであるクラスを設計する(例えばif(obj) { ...問題を提示したようなT::operator bool() const;などのユーザー定義の変換関数、与えられた、暗黙の変換シーケンスは、1つの追加標準を許可結果boolがそのようなコードを可能にする、intに変換可能であることを意味し、その関数呼び出しの後、変換シーケンスobj << 1;またはint i=test;.
Original:
Until the introduction of explicit conversion functions in C++11, designing a class that should be usable in boolean contexts (e.g. if(obj) { ... presented a problem: given a user-defined conversion function, such as T::operator bool() const;, the implicit conversion sequence allowed one additional standard conversion sequence after that function call, which means the resultant bool could be converted to int, allowing such code as obj << 1; or int i=test;.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
このための一つの早期解決は、std::basic_iosoperator!operator void*()を定義(C++11以前)で見ることができるように、コードif(std::cin) {...void*に変換できるので、boolはコンパイルしますが、int n = std::cout;void*に変換することができないので、intはコンパイルされませんよう。これはまだそのようなdelete std::cout;としてナンセンスコードをコンパイルすることができ、多くの事前のC + 11サードパーティ製のライブラリを使用して設計されたSafe Bool idiom.
Original:
One early solution for this can be seen in std::basic_ios, which defines operator! and operator void*()(C++11以前), so that the code such as if(std::cin) {... compiles because void* is convertible to bool, but int n = std::cout; does not compile because void* is not convertible to int. This still allows nonsense code such as delete std::cout; to compile, and many pre-C++11 third party libraries were designed with a more elaborate solution, known as the Safe Bool idiom.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] も参照してください