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 =
19
decltype
(Write(std::declval<
Writer
&>(), std::declval<
const
T&>()));
20
21
template
<
typename
T>
22
using
ReadableResult =
decltype
(Read(std::declval<
Reader
&>(), To<T>{}));
23
24
}
// namespace impl
25
26
/// Check if `writer.Write(T)` is available
27
template
<
typename
T
>
28
inline
constexpr
bool
kIsWritable
=
29
std
::
is_same_v
<
meta
::
DetectedType
<
impl
::
WritableResult
,
T
>,
void
>;
30
31
/// Check if `reader.Read<T>()` is available
32
template
<
typename
T
>
33
inline
constexpr
bool
kIsReadable
=
34
std
::
is_same_v
<
meta
::
DetectedType
<
impl
::
ReadableResult
,
T
>,
35
std
::
remove_const_t
<
T
>>;
36
37
/// Check if `T` is both writable and readable
38
template
<
typename
T
>
39
inline
constexpr
bool
kIsDumpable
=
kIsWritable
<
T
> &&
kIsReadable
<
T
>;
40
41
template
<
typename
T>
42
constexpr
bool
CheckDumpable() {
43
static_assert
(
44
kIsDumpable<T>,
45
"Type is not dumpable. Probably you forgot to include "
46
"<userver/dump/common.hpp>, <userver/dump/common_containers.hpp> or "
47
"other headers with Read and Write declarations"
);
48
49
return
true
;
50
}
51
52
}
// namespace dump
53
54
USERVER_NAMESPACE_END
userver
dump
meta.hpp
Generated on Wed May 15 2024 22:35:10 for userver by
Doxygen
1.10.0