forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IntrusiveDetails.h
41 lines (33 loc) · 819 Bytes
/
IntrusiveDetails.h
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 <[email protected]>
*
* 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> {
};
}