-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove_const.h
More file actions
43 lines (34 loc) · 883 Bytes
/
remove_const.h
File metadata and controls
43 lines (34 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//
// Created by Makram Kamaleddine on 10/28/15.
//
#ifndef MY_MPL_REMOVE_CONST_H
#define MY_MPL_REMOVE_CONST_H
namespace mpl {
// a metafunction that takes a type
// that is const or volatile qualified
// and removes this qualifier
// no cv qualifiers: return the type given
template<typename T>
struct remove_cv {
using type = T;
};
// const qualifier
template<typename U>
struct remove_cv<U const> {
using type = U;
};
// volatile qualifier
template<typename V>
struct remove_cv<V volatile> {
using type = V;
};
// const volatile
template<typename W>
struct remove_cv<W const volatile> {
using type = W;
};
// alias template for better readability
template<typename T>
using remove_cv_t = typename remove_cv<T>::type;
}
#endif //MY_MPL_REMOVE_CONST_H