util/IntrusiveList: move struct HookDetection to top-level

This commit is contained in:
Max Kellermann
2022-06-08 21:39:53 +02:00
committed by Max Kellermann
parent e7b587d550
commit c28580745b

View File

@@ -102,25 +102,25 @@ public:
} }
}; };
/**
* Detect the hook type; this is important because
* SafeLinkIntrusiveListHook::unlink() needs to clear the "next"
* pointer. This is a template to postpone the type checks, to allow
* forward-declared types.
*/
template<typename U>
struct IntrusiveListHookDetection {
static_assert(std::is_base_of_v<IntrusiveListHook, U>);
using type = std::conditional_t<std::is_base_of_v<SafeLinkIntrusiveListHook, U>,
SafeLinkIntrusiveListHook,
IntrusiveListHook>;
};
template<typename T> template<typename T>
class IntrusiveList { class IntrusiveList {
/**
* Detect the hook type; this is important because
* SafeLinkIntrusiveListHook::unlink() needs to clear the
* "next" pointer. This is a template to postpone the type
* checks, to allow forward-declared types.
*/
template<typename U> template<typename U>
struct HookDetection { using Hook = typename IntrusiveListHookDetection<U>::type;
static_assert(std::is_base_of_v<IntrusiveListHook, U>);
using type = std::conditional_t<std::is_base_of_v<SafeLinkIntrusiveListHook, U>,
SafeLinkIntrusiveListHook,
IntrusiveListHook>;
};
template<typename U>
using Hook = typename HookDetection<U>::type;
IntrusiveListNode head{&head, &head}; IntrusiveListNode head{&head, &head};