std::is_abstract
Aus cppreference.com
<metanoindex/>
<tbody> </tbody>| definiert in Header <type_traits>
|
||
template< class T > struct is_abstract; |
(seit C++11) | |
Wenn
T eine abstrakte Klasse (das heißt, eine Klasse, oder erklärt, erbt mindestens eine rein virtuelle Funktion) ist, stellt das Mitglied konstanten value gleich true. Für jede andere Art, value ist false .Original:
If
T is an abstract class (that is, a class that declares or inherits at least one pure virtual function), 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 [statisch] |
true wenn T is an abstract class type , false anders Original: true if T is an abstract class type , 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>
|
Notes
Abstrakte Klassen können nur als Basisklassen verwendet werden; keine Objekte einer abstrakten Klasse Typ kann außer in Form von Basisklasse Unterobjekte erstellt werden .
Original:
Abstract classes may only be used as base classes; no objects of an abstract class type can be created except in form of base class subobjects.
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.
Eine abstrakte Klasse kann von einer Klasse, die nicht abstrakt ist, wenn eine rein virtuelle Funktion überschreibt eine virtuelle Funktion, die nicht rein abgeleitet werden .
Original:
An abstract class may be derived from a class that is not abstract if a pure virtual function overrides a virtual function that is not pure.
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.
Beispiel
#include <iostream>
#include <type_traits>
struct A {
int m;
};
struct B {
virtual void foo();
};
struct C {
virtual void foo() = 0;
};
struct D : C {};
int main()
{
std::cout << std::boolalpha;
std::cout << std::is_abstract<A>::value << '\n';
std::cout << std::is_abstract<B>::value << '\n';
std::cout << std::is_abstract<C>::value << '\n';
std::cout << std::is_abstract<D>::value << '\n';
}
Output:
false
false
true
true
