diff --git a/AK/IntrusiveListRelaxedConst.h b/AK/IntrusiveListRelaxedConst.h new file mode 100644 index 0000000000..a305c08a8c --- /dev/null +++ b/AK/IntrusiveListRelaxedConst.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2021, the SerenityOS developers. + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include + +namespace AK { + +template T::*member> +class IntrusiveListRelaxedConst : public IntrusiveList { + AK_MAKE_NONCOPYABLE(IntrusiveListRelaxedConst); + AK_MAKE_NONMOVABLE(IntrusiveListRelaxedConst); + +public: + using IntrusiveList::IntrusiveList; + + using Iterator = IntrusiveList::Iterator; + + Iterator begin() const { return const_cast(this)->IntrusiveList::begin(); } + Iterator end() const { return Iterator {}; } +}; + +} + +using AK::IntrusiveListRelaxedConst;