class template
<type_traits>
std::remove_volatiletemplate <class T> struct remove_volatile;
Remove volatile qualification
Obtains the type T without top-level volatile qualification.The transformed type is aliased as member type remove_volatile::type.
If T is volatile-qualified, this is the same type as T but with its volatile-qualification removed. Otherwise, it is T unchanged.
Notice that this class merely obtains a type using another type as model, but it does not transform values or objects between those types. To explicitly remove the volatile-qualifier of an object, const_cast can be used.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// remove_volatile example
#include <iostream>
#include <type_traits>
int main() {
typedef volatile int vint;
std::remove_volatile<vint>::type a; // int a
std::remove_volatile<const volatile int>::type b = 0; // const int b
std::remove_volatile<volatile int*>::type c; // volatile int* c
std::remove_volatile<int* volatile>::type d; // int* d
if (std::is_volatile<decltype(d)>::value)
std::cout << "type of d is volatile" << std::endl;
else
std::cout << "type of d is not volatile" << std::endl;
return 0;
}
type of d is not volatile
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4