userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
meta_light.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/utils/meta_light.hpp
4
/// @brief Lightweight concepts
5
/// @see userver/utils/meta.hpp for more concepts
6
/// @ingroup userver_universal
7
8
// Don't add new includes here! Put concepts that require them in meta.hpp.
9
#
include
<
type_traits
>
10
11
USERVER_NAMESPACE_BEGIN
12
13
namespace
meta {
14
15
namespace
impl {
16
17
template
<
template
<
typename
...>
typename
Template,
typename
T>
18
struct
IsInstantiationOf : std::false_type {};
19
20
template
<
template
<
typename
...>
typename
Template,
typename
... Args>
21
struct
IsInstantiationOf<Template, Template<Args...>> : std::true_type {};
22
23
}
// namespace impl
24
25
#
ifndef
ARCADIA_ROOT
26
27
/// @brief Checks whether a trait is correct for the given template args
28
///
29
/// @deprecated Use a `requires` expression directly:
30
/// @code
31
/// if constexpr (requires { typename T::ValueType; }) { ... }
32
/// @endcode
33
template
<
template
<
typename
...>
typename
Trait,
typename
... Args>
34
concept
IsDetected =
requires
{
typename
Trait<Args...>; };
35
36
#
endif
37
38
/// @brief Returns `true` if the type is an instantiation of the specified template.
39
template
<
typename
T,
template
<
typename
...>
typename
Template>
40
concept
IsInstantiationOf = impl::IsInstantiationOf<Template, T>::value;
41
42
/// @brief Returns `true` if the type (with remove cv-qualifiers) is an instantiation of the specified template.
43
template
<
typename
T,
template
<
typename
...>
typename
Template>
44
concept
IsCvInstantiationOf = IsInstantiationOf<std::remove_cv_t<T>, Template>;
45
46
/// Returns `true` if the type is a fundamental character type.
47
/// `signed char` and `unsigned char` are not character types.
48
template
<
typename
T>
49
concept
IsCharacter =
50
std::is_same_v<T,
char
> || std::is_same_v<T,
wchar_t
> || std::is_same_v<T,
char16_t
> || std::is_same_v<T,
char32_t
>;
51
52
/// Returns `true` if the type is a true integer type (not `*char*` or `bool`)
53
/// `signed char` and `unsigned char` are integer types
54
template
<
typename
T>
55
concept
IsInteger = std::is_integral_v<T> && !IsCharacter<T> && !std::is_same_v<T,
bool
>;
56
57
/// @brief Returns `true` if the type is an instantiation of the specified template.
58
/// @deprecated Use @ref meta::IsInstantiationOf instead.
59
template
<
template
<
typename
...>
typename
Template,
typename
T>
60
// NOLINTNEXTLINE(readability-identifier-naming)
61
concept
kIsInstantiationOf = IsInstantiationOf<T, Template>;
62
63
/// @brief Returns `true` if the type (with remove cv-qualifiers) is an instantiation of the specified template.
64
/// @deprecated Use @ref meta::IsCvInstantiationOf instead.
65
template
<
template
<
typename
...>
typename
Template,
typename
T>
66
// NOLINTNEXTLINE(readability-identifier-naming)
67
concept
kIsCvInstantiationOf = IsCvInstantiationOf<T, Template>;
68
69
/// @brief Returns `true` if the type is a true integer type (not `*char*` or `bool`)
70
/// `signed char` and `unsigned char` are integer types
71
/// @deprecated Use @ref meta::IsInteger instead.
72
template
<
typename
T>
73
// NOLINTNEXTLINE(readability-identifier-naming)
74
concept
kIsInteger = IsInteger<T>;
75
76
}
// namespace meta
77
78
USERVER_NAMESPACE_END
userver
utils
meta_light.hpp
Generated on
for userver by
Doxygen
1.17.0