Namespaces
Variants

std:: is_volatile

From cppreference.net
Metaprogramming library
Type traits
Type categories
(C++11)
(C++11) ( DR* )
Type properties
(C++11)
is_volatile
(C++11)
(C++11)
(C++14)
(C++11) (deprecated in C++26)
(C++11) ( until C++20* )
(C++11) (deprecated in C++20)
(C++11)
Type trait constants
Metafunctions
(C++17)
Supported operations
Relationships and property queries
Type modifications
Type transformations
(C++11) (deprecated in C++23)
(C++11) (deprecated in C++23)
(C++11)
(C++11) ( until C++20* ) (C++17)

Compile-time rational arithmetic
Compile-time integer sequences
Definiert im Header <type_traits>
template < class T >
struct is_volatile ;
(seit C++11)

std::is_volatile ist ein UnaryTypeTrait .

Falls T ein volatile-qualifizierter Typ ist (also volatile oder const volatile ), liefert die Memberkonstante value den Wert true . Für alle anderen Typen ist value gleich false .

Wenn das Programm Spezialisierungen für std::is_volatile oder std::is_volatile_v hinzufügt, ist das Verhalten undefiniert.

Inhaltsverzeichnis

Template-Parameter

T - ein zu prüfender Typ

Hilfsvariablen-Template

template < class T >
constexpr bool is_volatile_v = is_volatile < T > :: value ;
(seit C++17)

Geerbt von std:: integral_constant

Member-Konstanten

value
[static]
true falls T ein volatile-qualifizierter Typ ist, false andernfalls
(ö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 T> struct is_volatile : std::false_type {};
template<class T> struct is_volatile<volatile T> : std::true_type {};

Beispiel

#include <type_traits>
#include <valarray>
static_assert(!std::is_volatile_v<int>);
static_assert(std::is_volatile_v<volatile int>);
static_assert(std::is_volatile_v<volatile const int>);
static_assert(std::is_volatile_v<volatile std::valarray<float>>);
static_assert(!std::is_volatile_v<std::valarray<volatile float>>);
int main() {}

Siehe auch

(C++11)
prüft, ob ein Typ const-qualifiziert ist
(Klassentemplate)