reinterpret_cast conversion
Aus cppreference.com
![]() |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
Konvertiert zwischen verschiedenen Arten von Neuinterpretation der zugrunde liegenden Bit-Muster .
Original:
Converts between types by reinterpreting the underlying bit pattern.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Inhaltsverzeichnis |
[Bearbeiten] Syntax
reinterpret_cast < new_type > ( expression )
|
|||||||||
Gibt einen Wert vom Typ
new_type
.Original:
Returns a value of type
new_type
.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[Bearbeiten] Erklärung
Im Gegensatz zu static_cast, aber wie const_cast, wird die reinterpret_cast Ausdruck zu keinen CPU-Anweisungen kompilieren. Es ist eine reine Compiler-Direktive, die den Compiler, um die Sequenz von Bits (Objekt-Repräsentation) von expression zu behandeln, als ob es die Art new_type hatten weist .
Original:
Unlike static_cast, but like const_cast, the reinterpret_cast expression does not compile to any CPU instructions. It is purely a compiler directive which instructs the compiler to treat the sequence of bits (object representation) of expression as if it had the type new_type.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Nur die folgenden Konvertierungen können mit reintepret_cast getan werden, außer wenn solche Umwandlungen würde werfen Konstantheit oder Volatilität .
Original:
Only the following conversions can be done with reintepret_cast, except when such conversions would cast away constness or volatility.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
1)
Ein Ausdruck der integralen, Aufzählung, Zeiger oder Zeiger-auf-Member-Typ kann seinen eigenen Typ konvertiert werden. Der resultierende Wert ist der gleiche wie der Wert des
expression
. (seit C++11)Original:
An expression of integral, enumeration, pointer, or pointer-to-member type can be converted to its own type. The resulting value is the same as the value of
expression
. (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.
You can help to correct and verify the translation. Click here for instructions.
2)
Jeder Zeiger kann auf jedem integralen Typ, der groß genug ist, um den Wert des Zeigers (zB um std::uintptr_t) halten umgewandelt werden
Original:
Any pointer can be converted to any integral type large enough to hold the value of the pointer (e.g. to std::uintptr_t)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
3)
Ein Wert beliebigen integraler oder Aufzählungstyp kann in einen Zeiger umgewandelt werden. Ein Zeiger umgewandelt in eine ganze Zahl von ausreichender Größe und zurück zu der gleichen Zeigertyp ist gewährleistet auf seinen ursprünglichen Wert sein, da ansonsten die resultierende Zeiger nicht sicher aufgelöst werden. Die Null-Pointer-Konstante NULL oder ganze Zahl Null ist nicht garantiert, dass die Null-Zeiger-Wert der Zieltyp ergeben; static_cast oder <div class="t-tr-text">implizite Konvertierung
sollte für diesen Zweck verwendet werden .Original:
implicit conversion
The text has been machine-translated via [http://translate.google.com Google Translate].
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.
Original:
A value of any integral or enumeration type can be converted to a pointer type. A pointer converted to an integer of sufficient size and back to the same pointer type is guaranteed to have its original value, otherwise the resulting pointer cannot be dereferenced safely. The null pointer constant NULL or integer zero is not guaranteed to yield the null pointer value of the target type; static_cast or
implizite Konvertierung</div> should be used for this purpose.
Original:
implicit conversion
The text has been machine-translated via [http://translate.google.com Google Translate].
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
4)
Jeder Wert des Typs std::nullptr_t, einschließlich nullptr kann auf einen beliebigen ganzzahligen Typ konvertiert werden, als ob es (void*)0 war, aber kein Wert, nicht einmal nullptr können std::nullptr_t umgewandelt werden: static_cast sollte zu diesem Zweck verwendet werden. (seit C++11)
Original:
Any value of type std::nullptr_t, including nullptr can be converted to any integral type as if it was (void*)0, but no value, not even nullptr can be converted to std::nullptr_t: static_cast should be used for that purpose. (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.
You can help to correct and verify the translation. Click here for instructions.
5)
Jeder Zeiger auf Objekt des Typs
T1
können Zeiger auf Objekt eines anderen Typs T2
umgewandelt werden. Wenn T2
die Ausrichtung Anforderung ist nicht strenger als T1
die, Umwandlung der resultierenden Zeiger wieder in seinen ursprünglichen Typ Erträge der ursprüngliche Wert, da sonst die resultierende Zeiger kann nicht sicher dereferenziert werden. In jedem Fall kann die resultierende Zeiger nur sicher aufgelöst werden, wenn durch die Typ Aliasing Regeln (siehe unten) erlaubt Original:
Any pointer to object of type
T1
can be converted to pointer to object of another type T2
. If T2
's alignment requirement is not stricter than T1
's, conversion of the resulting pointer back to its original type yields the original value, otherwise the resulting pointer cannot be dereferenced safely. In any case, the resulting pointer may only be dereferenced safely if allowed by the type aliasing rules (see below) The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
6)
Ein L-Wert Ausdruck des Typs
T1
umgewandelt in einen anderen Typ T2
verweisen. Das Ergebnis ist ein L-Wert oder xWert Bezugnahme auf dasselbe Objekt wie das Original Lvalue, aber mit einem anderen Typ. Keine temporäre erstellt wird, keine Kopie erstellt wird, werden keine Konstruktoren oder Umwandlung Funktionen aufgerufen. Der resultierende Sollwert kann nur sicher zugegriffen werden, wenn durch die Typ Aliasing Regeln (siehe unten) erlaubtOriginal:
An lvalue expression of type
T1
can be converted to reference to another type T2
. The result is an lvalue or xvalue referring to the same object as the original lvalue, but with a different type. No temporary is created, no copy is made, no constructors or conversion functions are called. The resulting reference can only be accessed safely if allowed by the type aliasing rules (see below)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
7)
Jeder Zeiger auf Funktion kann auf einen Zeiger auf eine andere Funktion umgewandelt werden. Der Aufruf der Funktion durch einen Zeiger auf eine andere Funktion Typ undefined, sondern Umwandlung solcher Zeiger wieder auf Zeiger auf die ursprüngliche Funktion type liefert den Zeiger auf die ursprüngliche Funktion .
Original:
Any pointer to function can be converted to a pointer to a different function type. Calling the function through a pointer to a different function type is undefined, but converting such pointer back to pointer to the original function type yields the pointer to the original function.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
8)
In einigen Implementierungen (insbesondere auf jedem POSIX-kompatiblen System) kann eine Funktion Zeiger auf ein Objekt Zeiger oder umgekehrt umgewandelt werden. Wenn die Implementierung unterstützt die Konvertierung in beide Richtungen, die Umstellung auf den ursprünglichen Typ liefert den ursprünglichen Wert, da sonst die resultierende Zeiger kann nicht dereferenziert oder aufgerufen werden sicher .
Original:
On some implementations (in particular, on any POSIX compatible system), a function pointer can be converted to an object pointer or vice versa. If the implementation supports conversion in both directions, conversion to the original type yields the original value, otherwise the resulting pointer cannot be dereferenced or called safely.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
9)
Die Null-Zeiger-Wert von jeder Zeigertyp kann an jeden anderen Zeigertyp, was in der Null-Zeiger Wert dieses Typs umgewandelt werden. Beachten Sie, dass die Null-Pointer-Konstante nullptr oder irgendein anderer Wert vom Typ std::nullptr_t nicht auf einen Zeiger mit reinterpret_cast umgewandelt werden: implizite Konvertierung oder static_cast sollte für diesen Zweck verwendet werden .
Original:
The null pointer value of any pointer type can be converted to any other pointer type, resulting in the null pointer value of that type. Note that the null pointer constant nullptr or any other value of type std::nullptr_t cannot be converted to a pointer with reinterpret_cast: implicit conversion or static_cast should be used for this purpose.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
10)
Ein rvalue Zeiger auf Elementfunktion kann Zeiger auf einen anderen Member-Funktion von einem anderen Typ umgewandelt werden. Die Umstellung auf den ursprünglichen Typ liefert den ursprünglichen Wert, da sonst die resultierende Zeiger kann nicht sicher verwendet werden .
Original:
An rvalue pointer to member function can be converted to pointer to a different member function of a different type. Conversion to the original type yields the original value, otherwise the resulting pointer cannot be used safely.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
11)
Ein rvalue Zeiger auf Member-Objekt von irgendeiner Klasse
T1
kann auf einen Zeiger auf ein anderes Mitglied Objekt einer anderen Klasse T2
umgewandelt werden. Wenn T2
die Ausrichtung ist nicht strenger als T1
die, die Umstellung auf den ursprünglichen Typ Erträge der ursprüngliche Wert, da sonst die resultierende Zeiger kann nicht sicher verwendet werden .Original:
An rvalue pointer to member object of some class
T1
can be converted to a pointer to another member object of another class T2
. If T2
's alignment is not stricter than T1
's, conversion to the original type yields the original value, otherwise the resulting pointer cannot be used safely.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Wie bei allen Besetzung Ausdrücke, ist das Ergebnis:
Original:
As with all cast expressions, the result is:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
- ein L-Wert, wenn new_type ist ein L-Wert Referenz-Typ oder ein rvalue Bezug auf Art funktionieren;Original:an lvalue if new_type is an lvalue reference type or an rvalue reference to function type;The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - ein xWert wenn new_type ist ein rvalue Verweis auf Objekttyp;Original:an xvalue if new_type is an rvalue reference to object 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 sonst .Original:a prvalue otherwise.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.