class template
<type_traits>
std::remove_consttemplate <class T> struct remove_const;
Remove const qualification
Obtains the type T without top-level const qualification.The transformed type is aliased as member type remove_const::type.
If T is const-qualified, this is the same type as T but with its const-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 const-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_const example
#include <iostream>
#include <type_traits>
int main() {
typedef const char cc;
std::remove_const<cc>::type a; // char a
std::remove_const<const char*>::type b; // const char* b
std::remove_const<char* const>::type c; // char* c
a = 'x';
b = "remove_const";
c = new char[10];
std::cout << b << std::endl;
return 0;
}
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