Namensräume
Varianten
Aktionen

Implicit conversions

Aus cppreference.com
< cpp‎ | language

 
 
Sprache C++
Allgemeine Themen
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.
Flusskontrolle
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.
Bedingte Ausführung Aussagen
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.
Iterationsanweisungen
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.
Gehe Aussagen
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.
Funktionen
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Funktion Erklärung
Lambda-Funktion Erklärung
Funktions-Template
inline-Spezifizierer
Exception-Spezifikationen (veraltet)
noexcept Spezifizierer (C++11)
Ausnahmen
Original:
Exceptions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Namespaces
Original:
Namespaces
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Types
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)
Specifiers
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 Planer
Lagerdauer Planer
constexpr Spezifizierer (C++11)
auto Spezifizierer (C++11)
alignas Spezifizierer (C++11)
Initialisierung
Original:
Initialization
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Literale
Original:
Literals
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Expressions
Original:
Expressions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
alternative Darstellungen
Utilities
Original:
Utilities
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Types
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
Typ Aliasdeklaration (C++11)
Attribute (C++11)
Wirft
Original:
Casts
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
impliziten Konvertierungen
const_cast conversion
static_cast conversion
dynamic_cast conversion
reinterpret_cast conversion
C-Stil und funktionale Besetzung
Speicherzuweisung
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.
Classes
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Class-spezifische Funktion Eigenschaften
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.
explizit (C++11)
statisch
Besondere Member-Funktionen
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.
Templates
Original:
Templates
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Klassen-Template
Funktions-Template
Template-Spezialisierung
Parameter Packs (C++11)
Verschiedenes
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Inline Montage
 
Implizite Konvertierungen werden ausgeführt, wenn ein Ausdruck eines Typs T1 im Kontext welche nicht diese Art verwendet wird, akzeptiert aber eine andere Art T2, insbesondere:
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.
  • Wenn der Ausdruck als Argument verwendet wird beim Aufruf einer Funktion, die mit T2 als Parameter deklariert wird .
    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.
  • Wenn der Ausdruck als Operand mit einem Operator, T2 erwartet werden
    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.
  • Bei der Initialisierung eines neuen Objekts des Typs T2, einschließlich return Anweisung in einer Funktion, die 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.
  • Wenn der Ausdruck in einem switch Anweisung verwendet wird (T2 ist integraler Typ)
    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.
  • Wenn der Ausdruck in einem if Anweisung verwendet wird oder eine Schleife (T2 ist bool)
    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.
Das Programm ist wohlgeformt (kompiliert) nur, wenn es eine eindeutige implizite Konvertierung Sequenz aus T1 um T2 .
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.
Wenn es mehrere Überladungen der Funktion oder Operator aufgerufen, nachdem die implizite Konvertierung Sequenz von T1 an jede verfügbare T2 aufgebaut sind, entscheiden Überlast Auflösung Regeln, welche Überladung zusammengestellt .
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, Überlast Auflösung 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.

Inhaltsverzeichnis

[Bearbeiten] Reihenfolge der Conversions

Implizite Konvertierung Sequenz besteht aus den folgenden, in dieser Reihenfolge:
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)
Null oder Eins Standard Konvertierungssequenz
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)
Null oder Eins user-definierte Umwandlung
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)
Null oder ein Standard-Konvertierung Sequenz
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.
Bei der Betrachtung das Argument eines Konstruktors oder einer benutzerdefinierten Konvertierung Funktion, nur ein Standard-Konvertierung Sequenz erlaubt (sonst benutzerdefinierte Konvertierungen konnte effektiv verkettet). Bei der Umwandlung von einem eingebauten Typ in einen anderen integrierten Typ wird nur ein Standard-Konvertierung Sequenz erlaubt .
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.
Ein Standard-Konvertierung Sequenz besteht aus den folgenden, in dieser Reihenfolge:
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)
Null oder Eins lvalue Transformation
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)
Null oder Eins numerische Förderung oder numerischen Konvertierung
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)
Null oder Eins Qualifizierung Einstellung
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.
Eine benutzerdefinierte Konvertierung besteht aus:
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.
@ * @ Null oder ein nicht-expliziten Single-Argument-Konstruktor oder nicht explizite Konvertierung Funktionsaufruf
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.
Ein Ausdruck e soll implizit konvertierbar sein T2, wenn und nur wenn die Erklärung T2 t=e; wohlgeformt ist (zusammengestellt werden können), für einige erfunden temporäre t. Beachten Sie, dass dies anders aus T2 t(e), wo explizite Konstruktoren und Konvertierungsfunktionen zusätzlich würde betrachtet wird .
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.
Eine Ausnahme ist die obige Regel ist die spezielle implizite Konvertierung in den folgenden fünf Kontexten (seit C++11), wobei Typ bool wird erwartet aufgerufen:
Original:
One exception is the above rule is the special implicit conversion invoked in the following five contexts (seit 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.
  • Kontrolle der Expression if, while, for
    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.
  • die logischen Operatoren !, && und ||
    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.
  • der bedingte Operator ?:
    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
in solchen Kontexten ist implizite Konvertierung Reihenfolge gebaut werden, wenn die Erklärung bool t(e); ist wohlgeformt. das heißt, die explizite benutzerdefinierten Umwandlungsfunktion wie explicit T::operator bool() const; betrachtet. Solche Ausdruck e soll kontextuell konvertierbar sein bool .
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.

[Bearbeiten] Lvalue Transformationen

Lvalue Transformationen angewendet werden, wenn Lvalue Arguments (z. B. Referenz auf ein Objekt) im Kontext verwendet wird, wo rvalue (zB eine Zahl) wird erwartet .
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.

[Bearbeiten] Lvalue um rvalue Konvertierung

Ein glvalue jeder nicht-Funktion, nicht-Array-Typ T kann implizit umgewandelt werden, um vom gleichen Typ prvalue. Wenn T a non-class-Typ ist, diese Umwandlung beseitigt auch cv-Qualifikanten. Sofern in unevaluierten Kontext (in Operand sizeof, typeid, noexcept oder decltype), diese Umwandlung begegnet effektiv copy-baut ein temporäres Objekt vom Typ T mit dem ursprünglichen glvalue wie der Konstruktor Argument, und dass temporäre Objekt wird als prvalue zurückgegeben . Wenn die glvalue den Typ std::nullptr_t, ist die resultierende prvalue der Null-Zeiger konstanten 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.

[Bearbeiten] Array auf Zeiger-Konvertierung

Ein L-Wert oder rvalue vom Typ "Array von N T" oder "Array unbekannter des T gebunden" kann implizit in einen prvalue vom Typ "Zeiger auf T" umgewandelt. Die resultierende Zeiger verweist auf das erste Element des Arrays .
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.

[Bearbeiten] Funktion zum Zeiger

Ein L-Wert der Funktion vom Typ T kann implizit in einen prvalue Zeiger auf diese Funktion umgewandelt werden. Dies gilt nicht für nicht-statische Member-Funktionen anzuwenden, da lvalues, die nicht-statische Member-Funktionen beziehen sich nicht vorhanden .
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.

[Bearbeiten] Numerische Werbeaktionen

[Bearbeiten] Integral Promotion

Prvalues ​​von kleinen ganzzahligen Typen (wie char) kann prvalues ​​größeren ganzzahligen Typen (wie int) umgewandelt werden. Insbesondere dürfen arithmetischen Operatoren nicht akzeptieren Typen kleiner als int als Argumente und integraler Aktionen werden automatisch übernommen. Diese Umwandlung behält immer den Wert .
Original:
Prvalues of small integral types (such as char) may be converted to prvalues of larger integral types (such as int). In particular, arithmetischen Operatoren 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.
Die folgenden impliziten Konvertierungen sind als integrale Aktionen eingeteilt:
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 oder signed short können int umgewandelt werden .
    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 oder unsigned short können unsigned int umgewandelt werden .
    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 umgewandelt werden kann int oder unsigned int abhängig von der zugrunde liegenden Typ: signed char oder unsigned char (siehe oben)
    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_t, char16_t und char32_t kann zu dem ersten Typ aus der folgenden Liste in der Lage, den gesamten Wertebereich zu halten umgewandelt werden: int, unsigned int, long, unsigned long, long long, unsigned 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.
  • Ein ohne Bereichseinschränkung Enumeration Typ, dessen zugrunde liegender Typ ist nicht fixiert werden, um die erste Art aus der folgenden Liste können ihre gesamten Wertebereich zu halten umgewandelt werden: int, unsigned int, long, unsigned long, long long oder unsigned long long. Wenn der Wertebereich größer ist, gelten keine integralen Promotionen .
    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.
  • Ein ohne Bereichseinschränkung Enumeration Typ, dessen zugrunde liegenden Typ festgelegt ist kann seine förderte zugrunde liegenden Typ umgewandelt werden. (seit C++11)
    Original:
    An unscoped enumeration type whose underlying type is fixed can be converted to its promoted underlying type. (seit C++11)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • A Bitfeld Typ zu int umgewandelt werden kann, wenn es gesamten Wertebereich des Bitfeld, sonst unsigned int darstellen können, wenn sie gesamte Wertebereich des bitfield darstellen können, gelten ansonsten keine integralen Promotionen .
    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.
  • Die Art bool können int mit dem Wert umgewandelt werden false immer 0 und true immer 1 .
    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.

[Bearbeiten] Fließkomma-Förderung

A prvalue vom Typ float können prvalue vom Typ double umgewandelt werden. Der Wert ändert sich nicht .
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.

[Bearbeiten] Numerischen Konvertierungen

Im Gegensatz zu den Aktionen, können numerische Konvertierungen die Werte ändern, mit potenziellen Verlust an Präzision .
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.

[Bearbeiten] Integral Konvertierungen

A prvalue eines ganzzahligen Typs oder eines ohne Bereichseinschränkung Aufzählungstyp kann zu jedem anderen Integer-Typ umgewandelt werden. Wenn die Konvertierung unter integraler Aktionen aufgeführt ist, ist es eine Förderung und nicht eine Umwandlung .
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.
  • Wenn der Zieltyp nicht signiert ist, ist der resultierende Wert der Wert modulo 2n
    wo n ist die Anzahl der Bits verwendet, um die Art des Ziels darstellen. In 2-Komplement-Arithmetik (verwendet auf allen Plattformen, auf denen C + +-Compiler zur Verfügung stehen), ist diese Umwandlung ein no-op, mit Ausnahme der Kürzung, wenn der Zieltyp ist zu klein .
    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.
  • Wenn der Zieltyp unterzeichnet ist, ändert sich der Wert nicht ändern, wenn die Quelle ganze Zahl im Zieltyp dargestellt werden können. Ansonsten ist das Ergebnis durch die Implementierung definiert .
    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.
  • Wenn die Quell-Typ ist bool, wird der Wert auf Null false umgewandelt und der Wert true auf den Wert einer der Zieltyp (beachte, dass, wenn der Zieltyp int dies eine ganze Zahl Förderung, keine ganze Zahl Umwandlung ist) umgewandelt
    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.
  • Wenn der Zieltyp bool, dies ist ein boolean-Konvertierung (siehe unten)
    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.

[Bearbeiten] Floating-Point-Conversions

A prvalue einer Floating-Point-Typ konvertiert, um einer anderen Gleitkommatyp prvalue werden. Wenn die Konvertierung unter Floating-Point-Aktionen aufgeführt ist, ist es eine Förderung und nicht eine Umwandlung .
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.
  • Wenn die Quelle-Wert kann genau in der Zieltyp dargestellt werden, ist es nicht ändern .
    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.
  • Wenn der Quellwert zwischen zwei darstellbare Werte der Zieltyp, ist das Ergebnis einer dieser beiden Werte (sie wird das man Implementierung definiert)
    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.
  • Ansonsten ist das Verhalten nicht definiert .
    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.

[Bearbeiten] Floating - integraler Konvertierungen

  • A prvalue der Floating-Point-Typ konvertiert, um jeden Typ Integer prvalue werden. Der Bruchteil ist abgeschnitten, das heißt, der Bruchteil verworfen. Wenn der Wert nicht in den Zieltyp passen, ist das Verhalten undefiniert. Wenn der Zieltyp bool, dies ist ein boolean-Konvertierung (siehe unten) .
    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.
  • A prvalue von Integer oder ohne Bereichseinschränkung Aufzählungstyp umgewandelt zu jeder Gleitkommatyp prvalue werden. Wenn der Wert nicht korrekt dargestellt werden, ist es die Umsetzung definiert, ob die höhere oder am nächsten die nächsten unteren darstellbare Wert ausgewählt werden. Wenn der Wert nicht in den Zieltyp passen, ist das Verhalten undefiniert. Wenn die Quell-Typ ist bool, wird der Wert auf Null false umgewandelt, und der Wert wird an einen true überführt .
    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.

[Bearbeiten] Pointer Konvertierungen

  • Die' Nullzeiger konstanten NULL oder jede andere prvalue von integralen Typ, auf Null oder einem wertet prvalue vom Typ std::nullptr_t, einschließlich des Null-Zeiger' nullptr Literal, kann an jeden Zeigertyp umgewandelt werden, und das Ergebnis ist die Null-Zeiger-Wert dieses Typs. Eine solche Umwandlung (auch bekannt als "Null-Zeiger-Umstellung auf Konvergenz tot a cv-qualifizierter Typ als eine einzige Umwandlung, dh es wird ist nicht als eine Kombination von numerischen und Qualifying ein Umtausch zulässig) .
    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.
  • A prvalue Zeiger auf eine (optional cv-qualifiziert) Objekttyp T kann zu einer prvalue Zeiger umgewandelt werden (identisch cv-qualifiziert) void. Wenn nicht der T Laufzeittyp das spitze-zu-Objekt, wird das resultierende Zeiger eingestellt werden, um zu Beginn der Lagerung durch den meisten Ableitungen Objekt belegte zeigen. Wenn der ursprüngliche Zeiger ein Null-Zeiger-Wert, ist das Ergebnis eine Null-Zeiger-Wert der Zieltyp .
    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.
  • A prvalue Zeiger auf eine (gegebenenfalls cv-qualifiziert) abgeleiteten Klasse Typ konvertiert, um Zeiger auf seine zugängliche, eindeutige (identisch cv-qualifiziert) Basisklasse prvalue werden. Das Ergebnis der Konvertierung ist ein Zeiger auf die Basisklasse Unterobjekt innerhalb der spitzen-to-Objekt. Die Null-Zeiger wird auf den Null-Zeiger-Wert der Zieltyp konvertiert .
    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.

[Bearbeiten] Pointer-to-Mitglied Konvertierungen

  • Das Null-Zeiger Konstante NULL oder jede andere prvalue der ganzzahligen Typ, auf Null wertet oder einem prvalue vom Typ std::nullptr_t, einschließlich der Null-Zeiger wörtliche nullptr, kann auf jeden Zeiger-auf-Member-Typs umgewandelt werden, und das Ergebnis ist die Null-Zeiger-Wert dieses Typs. Eine solche Umwandlung (auch bekannt als "Null-Zeiger-Umstellung auf Konvergenz tot a cv-qualifizierter Typ als eine einzige Umwandlung, dh es wird ist nicht als eine Kombination von numerischen und Qualifying ein Umtausch zulässig) .
    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.
  • Prvalue Zeiger auf ein Element eines bestimmten Typs T in einer Basisklasse B umgewandelt Zeiger auf Elementfunktion des gleichen Typs T in seiner abgeleiteten Klasse D prvalue werden. Wenn B unzugänglichen, mehrdeutig oder virtuelle Basis D ist oder eine Basis einer intermediären virtuellen Basis D, ist die Umwandlung mangelhafte (nicht kompiliert). Die resultierende Zeiger kann mit einem D Objekt aufgelöst werden, und es wird das Element innerhalb der Basis B Subobjekt dieser D Objekt zuzugreifen. Die Null-Zeiger wird auf den Null-Zeiger-Wert der Zieltyp konvertiert .
    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.

[Bearbeiten] Boolean Konvertierungen

Prvalues ​​der integralen, Fließkomma-, ohne Bereichseinschränkung Aufzählung, Zeiger und Zeiger-auf-Member-Typen können prvalues ​​vom Typ bool umgewandelt werden .
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.
Der Wert Null (für integrale, Gleitkomma-und ohne Bereichseinschränkung Enumeration) und der Null-Zeiger und die Null-Zeiger-auf-Member Werte werden false. Alle anderen Werte werden 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.
Prvalue vom Typ std::nullptr_t einschließlich nullptr, kann vom Typ prvalue bool umgewandelt werden. Der resultierende Wert ist false. (seit C++11)
Original:
Prvalue of type std::nullptr_t, including nullptr, can be converted to prvalue of type bool. The resulting value is false. (seit C++11)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[Bearbeiten] Qualifikation Konvertierungen

  • A prvalue vom Typ Zeiger auf ein Element der cv-qualifizierter Typ T in der Klasse X umgewandelt Zeiger auf Elementfunktion von cv-qualifizierter Typ T in der Klasse X prvalue werden .
    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.
"More" cv qualifizierte bedeutet, dass
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.
  • Uneingeschränkten Typ kann const umgewandelt werden
    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.
  • Uneingeschränkten Typ kann volatile umgewandelt werden
    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.
  • Uneingeschränkten Typ kann const volatile umgewandelt werden
    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 Typ kann in const volatile umgewandelt werden
    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 Typ kann in const volatile umgewandelt werden
    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.
Für Multi-Level-Zeiger, gelten die folgenden Einschränkungen:
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.
Ein mehrstufiges Zeiger P1 die cv1
0
qualifizierte Zeiger auf cv1
1
qualifizierte Zeiger auf ... cv1
n-1
qualifizierte Zeiger auf cv1
n
qualifizierte T konvertierbar ist ein mehrstufiges Zeiger P1 die cv2
0
qualifizierte Zeiger auf cv2
1
qualifizierte Zeiger auf ... cv2
n-1
qualifizierte Zeiger auf cv2
n
qualifizierte T nur wenn
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.
  • Die Anzahl der Stufen n ist die gleiche für beide Zeiger
    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.
  • Wenn es eine const im cv1
    k
    Qualifikation auf einer bestimmten Ebene (andere als Ebene Null) von P1 besteht const in derselben Ebene cv2
    k
    von P2
    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.
  • Wenn es eine volatile im cv1
    k
    Qualifikation auf einer bestimmten Ebene (andere als Ebene Null) von P1 besteht in der gleichen volatile cv2
    k
    level von P2
    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.
  • Wenn auf einer bestimmten Ebene k die cv-Qualifikationen sind zwischen P1 und P2, dann muss es eine const auf jeder Ebene (außer Null) der P2 up ist bis 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.
  • Dieselben Regeln gelten für Multi-Level-Zeiger auf Elemente und Multi-Level gemischten Zeiger auf Objekte und Verweise auf Mitglieder .
    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.
  • Ebene Null wird nach den Regeln für Nicht-Multilevel-Qualifikation Konvertierungen angesprochen .
    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.
Insbesondere verbietet dies die Umwandlung von T** um const T**, aber die Umstellung auf const T* const* erlaubt ist .
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.

[Bearbeiten] Die sichere bool Problem

Bis zur Einführung der explizite Konvertierung Funktionen in C + +11, Gestaltung einer Klasse, die verwendbar sein sollte boolean Kontexte (z. B. if(obj) { ... stellte ein Problem: bei einer benutzerdefinierten Konvertierung Funktion, wie T::operator bool() const; erlaubte die implizite Konvertierung Sequenz eine zusätzliche Standard- Konvertierungssequenz nach diesem Funktionsaufruf, der auf das resultierende bool int umgewandelt werden konnte, so dass ein solcher Code als Mittel obj << 1; oder 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.
Eine frühe Lösung dafür ist in std::basic_ios, die operator! und operator void*()(bis C + +11) definiert gesehen werden, so dass der Code wie if(std::cin) {... kompiliert, weil void* konvertierbar bool ist, aber int n = std::cout; nicht kompilieren, da void* nicht konvertierbar int. Diese Methode ermöglicht Unsinn Code wie delete std::cout; zu kompilieren, und viele pre-C + 11 Drittanbieter-Bibliotheken wurden mit einem ausgelegt aufwendigere Lösung, bekannt als die Safe Bool idiom .
Original:
One early solution for this can be seen in std::basic_ios, which defines operator! and operator void*()(bis 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.

[Bearbeiten] Siehe auch