-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#ifndef ZLL_META_REMOVECV_HPP | ||
#define ZLL_META_REMOVECV_HPP | ||
|
||
namespace zll { | ||
namespace meta { | ||
|
||
// clang-format off | ||
template <typename T> struct remove_const { typedef T type; }; | ||
template <typename T> struct remove_const<const T> { typedef T type; }; | ||
// clang-format on | ||
|
||
// clang-format off | ||
template <typename T> struct remove_volatile { typedef T type; }; | ||
template <typename T> struct remove_volatile<volatile T> { typedef T type; }; | ||
// clang-format on | ||
|
||
// clang-format off | ||
template<typename T> struct remove_cv { typedef T type; }; | ||
template<typename T> struct remove_cv<const T> { typedef T type; }; | ||
template<typename T> struct remove_cv<volatile T> { typedef T type; }; | ||
template<typename T> struct remove_cv<const volatile T> { typedef T type; }; | ||
// clang-format on | ||
|
||
} // namespace meta | ||
} // namespace zll | ||
|
||
#endif // ZLL_META_ISSAME_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,7 @@ | |
|
||
#include "zll/meta/is_same.hpp" | ||
|
||
#include "zll/meta/remove_cv.hpp" | ||
|
||
|
||
#endif // ZLL_TYPETRAITS_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "zll/meta/remove_cv.hpp" | ||
#include "zll/meta/is_same.hpp" | ||
|
||
#include <utest.h> | ||
|
||
struct test_dummy {}; | ||
struct test_child : test_dummy {}; | ||
|
||
UTEST(meta_remove_cv, remove_const) { | ||
ASSERT_TRUE((zll::meta::is_same<zll::meta::remove_const<int>::type, int>::value)); | ||
ASSERT_TRUE((zll::meta::is_same<zll::meta::remove_const<const int>::type, int>::value)); | ||
ASSERT_TRUE((zll::meta::is_same<zll::meta::remove_const<volatile int>::type, volatile int>::value)); | ||
ASSERT_TRUE((zll::meta::is_same<zll::meta::remove_const<const volatile int>::type, volatile int>::value)); | ||
} | ||
|
||
UTEST(meta_remove_cv, remove_volatile) { | ||
ASSERT_TRUE((zll::meta::is_same<zll::meta::remove_volatile<int>::type, int>::value)); | ||
ASSERT_TRUE((zll::meta::is_same<zll::meta::remove_volatile<const int>::type, const int>::value)); | ||
ASSERT_TRUE((zll::meta::is_same<zll::meta::remove_volatile<volatile int>::type, int>::value)); | ||
ASSERT_TRUE((zll::meta::is_same<zll::meta::remove_volatile<const volatile int>::type, const int>::value)); | ||
} | ||
|
||
UTEST(meta_remove_cv, remove_cv) { | ||
ASSERT_TRUE((zll::meta::is_same<zll::meta::remove_cv<int>::type, int>::value)); | ||
ASSERT_TRUE((zll::meta::is_same<zll::meta::remove_cv<const int>::type, int>::value)); | ||
ASSERT_TRUE((zll::meta::is_same<zll::meta::remove_cv<volatile int>::type, int>::value)); | ||
ASSERT_TRUE((zll::meta::is_same<zll::meta::remove_cv<const volatile int>::type, int>::value)); | ||
} |