is_volatile 類別
測試類型是否為 volatile。
語法
template <class Ty>
struct is_volatile;
參數
Ty
要查詢的類型。
備註
如果 Ty 為 volatile-qualified
,則類型述詞的實例會保留 true。
範例
// std__type_traits__is_volatile.cpp
// compile with: /EHsc
#include <type_traits>
#include <iostream>
struct trivial
{
int val;
};
int main()
{
std::cout << "is_volatile<trivial> == " << std::boolalpha
<< std::is_volatile<trivial>::value << std::endl;
std::cout << "is_volatile<volatile trivial> == " << std::boolalpha
<< std::is_volatile<volatile trivial>::value << std::endl;
std::cout << "is_volatile<int> == " << std::boolalpha
<< std::is_volatile<int>::value << std::endl;
std::cout << "is_volatile<volatile int> == " << std::boolalpha
<< std::is_volatile<volatile int>::value << std::endl;
return (0);
}
is_volatile<trivial> == false
is_volatile<volatile trivial> == true
is_volatile<int> == false
is_volatile<volatile int> == true
需求
標頭:<type_traits>
命名空間:std