std:: negation
| Type traits | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Compile-time rational arithmetic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Compile-time integer sequences | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
(C++14)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Definiert im Header
<type_traits>
|
||
|
template
<
class
B
>
struct negation ; |
(seit C++17) | |
Bildet die logische Negation des Typmerkmals B .
Der Typ std :: negation < B > ist ein UnaryTypeTrait mit einer Basiseigenschaft von std:: bool_constant < ! bool ( B :: value ) > .
Wenn das Programm Spezialisierungen für
std::negation
oder
std::negation_v
hinzufügt, ist das Verhalten undefiniert.
Inhaltsverzeichnis |
Template-Parameter
| B | - | jeder Typ, für den der Ausdruck bool ( B :: value ) ein gültiger konstanter Ausdruck ist |
Hilfsvariablen-Template
|
template
<
class
B
>
constexpr bool negation_v = negation < B > :: value ; |
(seit C++17) | |
Geerbt von std:: integral_constant
Member-Konstanten
|
value
[static]
|
true
wenn
B
ein Member
::
value
besitzt, das bei expliziter Konvertierung zu
bool
false
ergibt, andernfalls
false
(öffentliche statische Member-Konstante) |
Member-Funktionen
|
operator bool
|
konvertiert das Objekt zu
bool
, gibt
value
zurück
(öffentliche Member-Funktion) |
|
operator()
(C++14)
|
gibt
value
zurück
(öffentliche Member-Funktion) |
Member-Typen
| Typ | Definition |
value_type
|
bool |
type
|
std:: integral_constant < bool , value > |
Mögliche Implementierung
template<class B> struct negation : std::bool_constant<!bool(B::value)> { }; |
Hinweise
| Feature-Test Makro | Wert | Std | Feature |
|---|---|---|---|
__cpp_lib_logical_traits
|
201510L
|
(C++17) | Logische Operator-Typ-Traits |
Beispiel
#include <type_traits> static_assert( std::is_same< std::bool_constant<false>, typename std::negation<std::bool_constant<true>>::type>::value, ""); static_assert( std::is_same< std::bool_constant<true>, typename std::negation<std::bool_constant<false>>::type>::value, ""); static_assert(std::negation_v<std::bool_constant<true>> == false); static_assert(std::negation_v<std::bool_constant<false>> == true); int main() {}
Siehe auch
|
(C++17)
|
variadische logische UND-Metafunktion
(Klassentemplate) |
|
(C++17)
|
variadische logische ODER-Metafunktion
(Klassentemplate) |
|
(C++11)
(C++17)
|
Kompilierzeitkonstante des angegebenen Typs mit angegebenem Wert
(Klassentemplate) |