Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- namespace op {
- // ------------------------------------
- template<typename T>
- struct remove_const {
- typedef T type;
- };
- template<typename T>
- struct remove_const<T const> {
- typedef T type;
- };
- template<typename T>
- using remove_const_t = typename remove_const<T>::type;
- // ------------------------------------
- template<typename T>
- struct remove_reference {
- typedef T type;
- };
- template<typename T>
- struct remove_reference<T&> {
- typedef T type;
- };
- template<typename T>
- struct remove_reference < T&& > {
- typedef T type;
- };
- template<typename T>
- using remove_reference_t = typename remove_reference<T>::type;
- // ------------------------------------
- }
- int main()
- {
- using T1 = op::remove_const<const std::string>::type; // C++11
- T1 str1 = "Das";
- str1 += " ist ein Test!";
- using T2 = op::remove_reference<T1&>::type; // C++11
- T2 str2 = "No more ref now";
- using T3 = op::remove_const_t<const std::string>; // C++14
- T3 str3 = "A string";
- op::remove_reference_t<T3&> str4 = "some string"; // C++14
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement