libcopp
2.3.1
Toggle main menu visibility
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
y
Functions
_
a
c
d
f
g
h
i
m
o
p
r
s
t
w
y
Variables
_
a
b
c
d
e
f
g
h
l
m
o
p
r
s
t
u
w
x
Typedefs
Enumerations
Enumerator
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
Data Fields
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
y
~
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
y
~
Variables
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Typedefs
_
a
b
c
d
e
f
h
i
j
l
m
n
o
p
r
s
t
u
v
w
Enumerations
Enumerator
e
l
s
u
Related Symbols
_
d
e
i
l
o
r
s
w
Files
File List
Globals
All
_
b
c
e
g
j
l
m
o
p
r
s
t
u
w
Functions
b
c
g
j
m
o
p
r
s
t
Variables
b
c
g
m
s
t
Typedefs
Enumerations
Enumerator
c
e
Macros
_
c
l
m
s
t
u
w
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Loading...
Searching...
No Matches
include
libcopp
utils
nostd
nullability.h
Go to the documentation of this file.
1
// Copyright 2025 owent
2
// Created by owent on 2025-03-03
3
4
#pragma once
5
6
#include <memory>
7
#include <type_traits>
8
9
#include "
libcopp/utils/config/compile_optimize.h
"
10
#include "libcopp/utils/config/libcopp_build_features.h"
11
#include "
libcopp/utils/nostd/type_traits.h
"
12
13
LIBCOPP_COPP_NAMESPACE_BEGIN
14
namespace
nostd
{
15
template
<
class
,
class
=
void
>
16
struct
__is_nullability_compatible
: ::std::false_type {};
17
18
// Allow custom to support nullability by define nullability_compatible_type as void
19
template
<
class
T>
20
struct
__is_nullability_compatible
<T, void_t<typename T::nullability_compatible_type>> : ::std::true_type {};
21
22
template
<
class
T>
23
struct
__is_nullability_support
{
24
LIBCOPP_UTIL_MACRO_INLINE_VARIABLE
static
constexpr
const
bool
value
=
__is_nullability_compatible<T>::value
;
25
};
23
struct
__is_nullability_support
{
…
};
26
27
template
<
class
T>
28
struct
__is_nullability_support
<T*> {
29
LIBCOPP_UTIL_MACRO_INLINE_VARIABLE
static
constexpr
const
bool
value =
true
;
30
};
28
struct
__is_nullability_support
<T*> {
…
};
31
32
template
<
class
T,
class
U>
33
struct
__is_nullability_support
<T U::*> {
34
LIBCOPP_UTIL_MACRO_INLINE_VARIABLE
static
constexpr
const
bool
value
=
true
;
35
};
33
struct
__is_nullability_support
<T U::*> {
…
};
36
37
template
<
class
T,
class
... Deleter>
38
struct
__is_nullability_support
<
std
::unique_ptr<T, Deleter...>> {
39
LIBCOPP_UTIL_MACRO_INLINE_VARIABLE
static
constexpr
const
bool
value
=
true
;
40
};
38
struct
__is_nullability_support
<
std
::unique_ptr<T, Deleter...>> {
…
};
41
42
template
<
class
T>
43
struct
__is_nullability_support
<
std
::shared_ptr<T>> {
44
LIBCOPP_UTIL_MACRO_INLINE_VARIABLE
static
constexpr
const
bool
value
=
true
;
45
};
43
struct
__is_nullability_support
<
std
::shared_ptr<T>> {
…
};
46
47
template
<
class
T>
48
struct
__enable_nullable
{
49
static_assert
(
__is_nullability_support<remove_cv_t<T>
>::value,
50
"Template argument must be a raw or supported smart pointer "
51
"type. See nostd/nullability.h."
);
52
using
type
= T;
53
};
48
struct
__enable_nullable
{
…
};
54
55
template
<
class
T>
56
struct
__enable_nonnull
{
57
static_assert
(
__is_nullability_support<remove_cv_t<T>
>::value,
58
"Template argument must be a raw or supported smart pointer "
59
"type. See nostd/nullability.h."
);
60
using
type
= T;
61
};
56
struct
__enable_nonnull
{
…
};
62
63
template
<
class
T>
64
struct
__enable_nullability_unknown
{
65
static_assert
(
__is_nullability_support<remove_cv_t<T>
>::value,
66
"Template argument must be a raw or supported smart pointer "
67
"type. See nostd/nullability.h."
);
68
using
type
= T;
69
};
64
struct
__enable_nullability_unknown
{
…
};
70
71
template <class T, class = typename __enable_nullable<T>::type>
72
using
nullable
73
#if LIBCOPP_UTIL_HAVE_CPP_ATTRIBUTE(clang::annotate)
74
[[clang::annotate(
"Nullable"
)]]
75
#endif
76
= T;
77
78
template <class T, class = typename __enable_nonnull<T>::type>
79
using
nonnull
80
#if LIBCOPP_UTIL_HAVE_CPP_ATTRIBUTE(clang::annotate)
81
[[clang::annotate(
"Nonnull"
)]]
82
#endif
83
= T;
84
85
template <class T, class = typename __enable_nullability_unknown<T>::type>
86
using
nullability_unknown
87
#if LIBCOPP_UTIL_HAVE_CPP_ATTRIBUTE(clang::annotate)
88
[[clang::annotate(
"Nullability_Unspecified"
)]]
89
#endif
90
= T;
91
92
}
// namespace nostd
14
namespace
nostd
{
…
}
93
LIBCOPP_COPP_NAMESPACE_END
compile_optimize.h
LIBCOPP_UTIL_MACRO_INLINE_VARIABLE
#define LIBCOPP_UTIL_MACRO_INLINE_VARIABLE
Definition
compile_optimize.h:612
nostd
Definition
nullability.h:14
nostd::nullability_unknown
T nullability_unknown
Definition
nullability.h:90
nostd::nullable
T nullable
Definition
nullability.h:76
nostd::nonnull
T nonnull
Definition
nullability.h:83
std
STL namespace.
type_traits.h
nostd::__enable_nonnull
Definition
nullability.h:56
nostd::__enable_nonnull::type
T type
Definition
nullability.h:60
nostd::__enable_nullability_unknown
Definition
nullability.h:64
nostd::__enable_nullability_unknown::type
T type
Definition
nullability.h:68
nostd::__enable_nullable
Definition
nullability.h:48
nostd::__enable_nullable::type
T type
Definition
nullability.h:52
nostd::__is_nullability_compatible
Definition
nullability.h:16
nostd::__is_nullability_support
Definition
nullability.h:23
nostd::__is_nullability_support::value
static LIBCOPP_UTIL_MACRO_INLINE_VARIABLE constexpr const bool value
Definition
nullability.h:24
Generated by
1.9.8