std::has_virtual_destructor
提供: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. |
| Defined in header <type_traits>
|
||
| template< class T > struct has_virtual_destructor; |
(C + + 11以来) | |
Tが仮想デストラクタを持つ型である場合、メンバーが一定提供value等しいtrueを。その他のタイプのために、valuefalseです.Original:
If
T is a type with a virtual 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.
目次 |
Inherited from std::integral_constant
Member constants
| value [静的] |
true T has a virtual destructor もし、そうでなければfalse Original: true if T has a virtual destructor , false otherwise The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共の静的メンバ定数) |
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. (パブリックメンバ関数) |
Member types
| タイプ
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> |
[編集] ノート
クラスがpublic仮想デストラクタを持っている場合、それが由来することができ、派生したオブジェクトを安全にベースオブジェクト(C++FAQ Lite 20.7)へのポインタを介して削除することができます
Original:
If a class has a public virtual destructor, it can be derived from, and the derived object can be safely deleted through a pointer to the base object (C++FAQ Lite 20.7)
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 <type_traits> #include <string> #include <stdexcept> int main() { std::cout << std::boolalpha << "std::string has a virtual destructor? " << std::has_virtual_destructor<std::string>::value << '\n' << "std::runtime_error has a virtual destructor? " << std::has_virtual_destructor<std::runtime_error>::value << '\n'; }
Output:
std::string has a virtual destructor? false std::runtime_error has a virtual destructor? true
[編集] も参照してください
| (C++11) (C++11) (C++11) |
タイプかどうかをチェックするには、非削除されたデストラクタを持っています Original: checks if a type has a non-deleted destructor The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (クラステンプレート) |