summaryrefslogtreecommitdiff
path: root/AK/IntrusiveDetails.h
blob: 1a86543693bed6d7ffbd1be334f2417349d40e63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
 * Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/NonnullRefPtr.h>

#ifdef KERNEL
#    include <Kernel/Library/LockRefPtr.h>
#endif
namespace AK::Detail {

template<typename T, typename Container>
struct SubstituteIntrusiveContainerType {
    using Type = Container;
};

template<typename T>
struct SubstituteIntrusiveContainerType<T, NonnullRefPtr<T>> {
    using Type = RefPtr<T>;
};

#ifdef KERNEL
template<typename T>
struct SubstituteIntrusiveContainerType<T, NonnullLockRefPtr<T>> {
    using Type = LockRefPtr<T>;
};
#endif

template<typename Container, bool _IsRaw>
struct SelfReferenceIfNeeded {
    Container reference = nullptr;
};
template<typename Container>
struct SelfReferenceIfNeeded<Container, true> {
};

}