/* Utilities for OctaSTD. * * This file is part of OctaSTD. See COPYING.md for futher information. */ #ifndef OCTA_UTILITY_H #define OCTA_UTILITY_H #include namespace octa { /* aliased in traits.h later */ namespace internal { template struct RemoveReference { typedef T type; }; template struct RemoveReference { typedef T type; }; template struct RemoveReference { typedef T type; }; template struct AddRvalueReference { typedef T &&type; }; template struct AddRvalueReference { typedef T &&type; }; template struct AddRvalueReference { typedef T &&type; }; template<> struct AddRvalueReference { typedef void type; }; template<> struct AddRvalueReference { typedef const void type; }; template<> struct AddRvalueReference { typedef volatile void type; }; template<> struct AddRvalueReference { typedef const volatile void type; }; } template static inline constexpr typename internal::RemoveReference::type && move(T &&v) noexcept { return static_cast::type &&>(v); } template static inline constexpr T && forward(typename internal::RemoveReference::type &v) noexcept { return static_cast(v); } template static inline constexpr T && forward(typename internal::RemoveReference::type &&v) noexcept { return static_cast(v); } template typename internal::AddRvalueReference::type declval(); template void swap(T &a, T &b) { T c(move(a)); a = move(b); b = move(c); } template void swap(T (&a)[N], T (&b)[N]) { for (size_t i = 0; i < N; ++i) { swap(a[i], b[i]); } } } #endif