class template
<type_traits>
std::add_cvtemplate <class T> struct add_cv;
Add const volatile qualification
Obtains the type T with both const and volatile qualification.The transformed type is aliased as member type add_cv::type.
If T is not already const- and volatile-qualified, and is neither a reference nor a function (which cannot be cv-qualified), this is the same type as T but const and volatile qualified. 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 add cv-qualification to 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
// add_cv example
#include <iostream>
#include <type_traits>
int main() {
typedef std::add_cv<int>::type A;
typedef std::add_cv<const int>::type B;
typedef std::add_cv<volatile int>::type C;
typedef std::add_cv<const volatile int>::type D;
std::cout << std::boolalpha;
std::cout << "typedefs of const volatile int:" << std::endl;
std::cout << "A: " << std::is_same<const volatile int,A>::value << std::endl;
std::cout << "B: " << std::is_same<const volatile int,B>::value << std::endl;
std::cout << "C: " << std::is_same<const volatile int,C>::value << std::endl;
std::cout << "D: " << std::is_same<const volatile int,D>::value << std::endl;
return 0;
}
typedefs of const volatile int: A: true B: true C: true D: true
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