<type_traits>

class template
<type_traits>

std::remove_volatile

template <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.

Template parameters

T
A type.

Member types

member typedefinition
typeIf T is volatile-qualified, the same type as T but with the volatile-qualification removed.
Otherwise, T

Example

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;
}

Output:
type of d is not volatile


See also