userver
C++ Async Framework
Loading...
Searching...
No Matches
meta.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/dump/meta.hpp
4
/// @brief Provides dump::kIsDumpable and includes userver/dump/fwd.hpp
5
6
#
include
<
type_traits
>
7
8
#
include
<
userver
/
dump
/
fwd
.
hpp
>
9
#
include
<
userver
/
utils
/
meta_light
.
hpp
>
10
11
USERVER_NAMESPACE_BEGIN
12
13
namespace
dump
{
14
15
namespace
impl {
16
17
template
<
typename
T>
18
using
WritableResult =
decltype
(Write(std::declval<Writer&>(), std::declval<
const
T&>()));
19
20
template
<
typename
T>
21
using
ReadableResult =
decltype
(Read(std::declval<Reader&>(), To<T>{}));
22
23
}
// namespace impl
24
25
/// Check if `writer.Write(T)` is available
26
template
<
typename
T
>
27
inline
constexpr
bool
kIsWritable
=
std
::
is_same_v
<
meta
::
DetectedType
<
impl
::
WritableResult
,
T
>,
void
>;
28
29
/// Check if `reader.Read<T>()` is available
30
template
<
typename
T
>
31
inline
constexpr
bool
kIsReadable
=
std
::
is_same_v
<
meta
::
DetectedType
<
impl
::
ReadableResult
,
T
>,
std
::
remove_const_t
<
T
>>;
32
33
/// Check if `T` is both writable and readable
34
template
<
typename
T
>
35
inline
constexpr
bool
kIsDumpable
=
kIsWritable
<
T
> &&
kIsReadable
<
T
>;
36
37
template
<
typename
T>
38
constexpr
bool
CheckDumpable() {
39
static_assert
(
40
kIsDumpable<T>,
41
"Type is not dumpable. Probably you forgot to include "
42
"<userver/dump/common.hpp>, <userver/dump/common_containers.hpp> or "
43
"other headers with Read and Write declarations"
44
);
45
46
return
true
;
47
}
48
49
}
// namespace dump
50
51
USERVER_NAMESPACE_END
userver
dump
meta.hpp
Generated on Wed Dec 4 2024 18:42:23 for userver by
Doxygen
1.10.0