std::is_destructible, std::is_trivially_destructible, std::is_nothrow_destructible
Материал из 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. |
| Заголовочный файл <type_traits>
|
||
| template< class T > struct is_destructible; |
(1) | (начиная с C++11) |
| template< class T > struct is_trivially_destructible; |
(2) | (начиная с C++11) |
| template< class T > struct is_nothrow_destructible; |
(3) | (начиная с C++11) |
Если мнимая структура, содержащая членом объекта типа
2) T имеет не удалил деструктор, обеспечивает постоянный член value равных true. Для любого другого типа, value является 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.
же, как и 1), но деструктор не вызывается любой операции, которая не является тривиальной.
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.
же, как и 1), но деструктор 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.
Содержание |
Унаследован от std::integral_constant
Member constants
| value [static] |
true если T is destructible, false иначе 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 константа-член) |
Member functions
| operator bool |
преобразует объект в bool, возвращает 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. (public функция-член) |
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> |
[править] Notes
Поскольку C + + программа завершается, если деструктор вызывает исключение во время раскручивания стека (которые обычно не могут быть предсказаны), все практические деструкторы не являются метания, даже если они не объявлены noexcept. Все деструкторы найти в C + + библиотеки стандартных номера для метания.
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.
[править] Пример
#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'; }
Вывод:
std::string is destructible? true Foo is nothrow destructible? true Bar is trivally destructible? true
[править] См. также
| (C++11) (C++11) (C++11) |
проверяет, является ли тип имеет конструктор для конкретных аргументов 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. (шаблон класса) |
| (C++11) |
проверяет, является ли тип имеет виртуальный деструктор 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. (шаблон класса) |