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