A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/type_traits/remove_cv/ below:

class template

<type_traits>

std::remove_cv
template <class T> struct remove_cv;

Remove cv qualification

Obtains the type T without any top-level const or volatile qualification.

The transformed type is aliased as member type remove_cv::type.

If T is cv-qualified (either const and/or volatile), this is the same type as T but with its cv-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 cv-qualifier of an object, const_cast can be used.



Template parameters
T
A type.

Member types member type definition type If T is cv-qualified, the same type as T but with any cv-qualification removed.
Otherwise, T
Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// remove_cv example
#include <iostream>
#include <type_traits>

int main() {
  typedef const volatile char cvchar;
  std::remove_cv<cvchar>::type a;       // char a
  std::remove_cv<char* const>::type b;  // char* b
  std::remove_cv<const char*>::type c;  // const char* c (no changes)

  if (std::is_const<decltype(a)>::value)
    std::cout << "type of a is const" << std::endl;
  else
    std::cout << "type of a is not const" << std::endl;

  if (std::is_volatile<decltype(a)>::value)
    std::cout << "type of a is volatile" << std::endl;
  else
    std::cout << "type of a is not volatile" << std::endl;

  return 0;
}

Output:
type of a is not const
type of a is not volatile


See also
add_cv
Add const volatile qualification (class template)
remove_const
Remove const qualification (class template)
remove_volatile
Remove volatile qualification (class template)
remove_reference
Remove reference (class template)
remove_pointer
Remove pointer (class template)

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