123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- #ifndef CORE_META_HPP
- #define CORE_META_HPP
- namespace Core {
- namespace Internal {
- template<typename T>
- struct BaseRemovePointer final {
- using Type = T;
- };
- template<typename T>
- struct BaseRemovePointer<T*> final {
- using Type = T;
- };
- template<typename T>
- struct BaseRemoveReference final {
- using Type = T;
- };
- template<typename T>
- struct BaseRemoveReference<T&> final {
- using Type = T;
- };
- template<typename T>
- struct BaseRemoveReference<T&&> final {
- using Type = T;
- };
- template<typename A, typename B>
- struct BaseIsSame final {
- static constexpr bool value = false;
- };
- template<typename T>
- struct BaseIsSame<T, T> final {
- static constexpr bool value = true;
- };
- template<bool C, typename A, typename B>
- struct BaseIf final {
- using Type = A;
- };
- template<typename A, typename B>
- struct BaseIf<false, A, B> final {
- using Type = B;
- };
- }
- template<typename T>
- using RemovePointer = Internal::BaseRemovePointer<T>::Type;
- template<typename T>
- using RemoveReference = Internal::BaseRemoveReference<T>::Type;
- template<typename T, typename U>
- constexpr bool IsSame = Internal::BaseIsSame<T, U>::value;
- template<bool C, typename A, typename B>
- using If = Internal::BaseIf<C, A, B>::Type;
- template<typename T>
- constexpr RemoveReference<T>&& move(T&& t) {
- return static_cast<RemoveReference<T>&&>(t);
- }
- template<typename T>
- constexpr T&& forward(RemoveReference<T>& t) {
- return static_cast<T&&>(t);
- }
- template<typename T>
- constexpr T&& forward(RemoveReference<T>&& t) {
- return static_cast<T&&>(t);
- }
- template<typename T>
- void swap(T& a, T& b) {
- T tmp = Core::move(a);
- a = Core::move(b);
- b = Core::move(tmp);
- }
- }
- #endif
|