class template
<type_traits>
std::remove_cvtemplate <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.
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;
}
type of a is not const type of a 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