std::is_destructible, std::is_trivially_destructible, std::is_nothrow_destructible
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. |
definiert in Header <type_traits> | ||
template<class T > struct is_destructible; | (1) | (seit C++11) |
template<class T > struct is_trivially_destructible; | (2) | (seit C++11) |
template<class T > struct is_nothrow_destructible; | (3) | (seit C++11) |
Wenn eine imaginäre struct enthaltend ein Element vom Typ
2) T
eine nicht gelöschte destructor, liefert das Element konstant value
gleich true. Für jede andere Art, value
ist false .Original:
If an imaginary struct containing a member object of type
T
has a non-deleted destructor, provides the member constant value
equal true. For any other type, value
is false.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 1), aber der Destruktor nicht aufgerufen sämtliche Aufgaben, die nicht trivial ist .
3) Original:
same as 1), but the destructor does not call any operation that is not trivial.
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 1), aber der Destruktor noexcept .
Original:
same as 1), but the destructor is noexcept.
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 |
Inherited from std::integral_constant
Member constants
value [statisch] | true wenn T is destructible, false anders Original: true if T is destructible, false otherwise The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public static Mitglied konstanten) |
Member functions
operator bool | wandelt das Objekt bool, gibt value Original: converts the object to bool, returns value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (öffentliche Elementfunktion) |
Member types
Type Original: Type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | Definition |
value_type | bool |
type | std::integral_constant<bool, value> |
[Bearbeiten]Notes
Da die C + +-Programm wird ein Destruktor löst eine Ausnahme während Stack Unwinding (die in der Regel nicht vorhergesagt werden kann), sind alle praktischen Destruktoren nicht werfen, auch wenn sie nicht deklariert noexcept. Alle Destruktoren in der C + +-Standard-Bibliothek zu finden sind non-Werfen .
Original:
Because the C++ program terminates if a destructor throws an exception during stack unwinding (which usually cannot be predicted), all practical destructors are non-throwing even if they are not declared noexcept. All destructors found in the C++ standard library are non-throwing.
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]Beispiel
#include <iostream>#include <string>#include <type_traits>struct Foo {std::string str; ~Foo()noexcept{};};struct Bar { ~Bar()=default;};int main(){std::cout<<std::boolalpha<<"std::string is destructible? "<< std::is_destructible<std::string>::value<<'\n'<<"Foo is nothrow destructible? "<< std::is_nothrow_destructible<Foo>::value<<'\n'<<"Bar is trivally destructible? "<< std::is_trivially_destructible<Bar>::value<<'\n';}
Output:
std::string is destructible? true Foo is nothrow destructible? true Bar is trivally destructible? true
[Bearbeiten]Siehe auch
(C++11) (C++11) (C++11) | prüft, ob ein Typ hat einen Konstruktor für Argumente Original: checks if a type has a constructor for specific arguments The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (Klassen-Template) |
(C++11) | prüft, ob ein Typ hat einen virtuellen Destruktor Original: checks if a type has a virtual destructor The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (Klassen-Template) |