util: add compile-time validation tests for intrusive red black trees

This commit is contained in:
Michael Scire 2021-04-21 05:06:11 -07:00
parent 57b6c71c1c
commit ed80d6ec8c
4 changed files with 288 additions and 56 deletions

View file

@ -550,7 +550,7 @@ namespace ams::util {
constexpr ALWAYS_INLINE const Derived *GetNext() const { return static_cast<const Derived *>(impl::IntrusiveRedBlackTreeImpl::GetNext(this)); }
};
template<class Derived>
template<class Derived> requires std::derived_from<Derived, IntrusiveRedBlackTreeNode>
class IntrusiveRedBlackTreeBaseTraits {
public:
template<class Comparator>

View file

@ -30,10 +30,10 @@ namespace ams::util {
bool active;
public:
constexpr ALWAYS_INLINE ScopeGuard(F f) : f(std::move(f)), active(true) { }
ALWAYS_INLINE ~ScopeGuard() { if (active) { f(); } }
ALWAYS_INLINE void Cancel() { active = false; }
constexpr ALWAYS_INLINE ~ScopeGuard() { if (active) { f(); } }
constexpr ALWAYS_INLINE void Cancel() { active = false; }
ALWAYS_INLINE ScopeGuard(ScopeGuard&& rhs) : f(std::move(rhs.f)), active(rhs.active) {
constexpr ALWAYS_INLINE ScopeGuard(ScopeGuard&& rhs) : f(std::move(rhs.f)), active(rhs.active) {
rhs.Cancel();
}