| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- module;
- export module Core.Meta;
- namespace Core {
- 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;
- };
- }
- export namespace Core {
- template<typename T>
- concept Iterable = requires(T& t) {
- t.begin();
- t.end();
- };
- template<typename T>
- using RemovePointer = BaseRemovePointer<T>::Type;
- template<typename T>
- using RemoveReference = BaseRemoveReference<T>::Type;
- template<typename T, typename U>
- constexpr bool IsSame = BaseIsSame<T, U>::value;
- template<bool C, typename A, typename B>
- using If = 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) noexcept {
- T tmp = Core::move(a);
- a = Core::move(b);
- b = Core::move(tmp);
- }
- }
|