feat(concept): add concepts that depend on templates such as Forward and add corresponding tests

This commit is contained in:
2022-02-04 15:47:57 +08:00
parent 3724188602
commit bafcadc68f
9 changed files with 279 additions and 15 deletions

View File

@ -0,0 +1,27 @@
#pragma once
#include "CoreTypes.h"
#include "Concepts/Common.h"
#include "Templates/Templates.h"
#include "TypeTraits/TypeTraits.h"
NAMESPACE_REDCRAFT_BEGIN
NAMESPACE_MODULE_BEGIN(Redcraft)
NAMESPACE_MODULE_BEGIN(Utility)
template <typename T>
concept CSwappable = requires(T& A, T& B) { Swap(A, B); };
template <typename T, typename U>
concept CSwappableWith = CCommonReferenceWith<T, U> &&
requires(T&& A, U&& B)
{
Swap(Forward<T>(A), Forward<T>(A));
Swap(Forward<U>(B), Forward<U>(B));
Swap(Forward<T>(A), Forward<U>(B));
Swap(Forward<U>(B), Forward<T>(A));
};
NAMESPACE_MODULE_END(Utility)
NAMESPACE_MODULE_END(Redcraft)
NAMESPACE_REDCRAFT_END