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
* SafeLinkIntrusiveListHook::unlink() needs to clear the
* "next" pointer. This is a template to postpone the type
* checks, to allow forward-declared types.
* 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 HookDetection {
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>
class IntrusiveList {
template<typename U>
using Hook = typename HookDetection<U>::type;
using Hook = typename IntrusiveListHookDetection<U>::type;
IntrusiveListNode head{&head, &head};