userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
meta.hpp
Go to the documentation of this file.
1
#pragma once
2
6
7
#include <type_traits>
8
9
#include <
userver/formats/parse/to.hpp
>
10
#include <
userver/formats/serialize/to.hpp
>
11
12
USERVER_NAMESPACE_BEGIN
13
14
namespace
formats::common
{
15
16
namespace
impl {
17
22
23
template
<
class
Value,
class
T>
24
concept
HasParse =
requires
(
const
Value& value) {
Parse
(value, parse::To<T>{}); };
25
26
template
<
class
Value,
class
T>
27
concept
HasSerialize =
requires
(
const
T& x) {
Serialize
(x, serialize::To<Value>{}); };
28
29
template
<
class
Value,
class
T>
30
concept
HasConvert =
requires
(
const
Value& value) { Convert(value, parse::To<T>{}); };
31
32
}
// namespace impl
33
36
template
<
class
Value>
37
concept
IsFormatValue
=
requires
{
typename
Value::ParseException; };
38
40
template
<
class
Value>
41
concept
kIsFormatValue
=
IsFormatValue<Value>
;
// NOLINT(readability-identifier-naming)
42
43
// Unwraps a transient type - tag types, for which ADL-found `Parse` returns
44
// another type, not the type specified in `formats::parse::To`. For example,
45
// there can be a `IntegerWithMin<42>` type that checks that the value contains
46
// a number `>= 42`, then parses and returns an `int`.
47
//
48
// For a normal type T, just returns the type T itself.
49
template
<
typename
Value,
typename
T>
50
using
ParseType =
decltype
(Parse(std::declval<Value>(),
parse::To<T>
()));
51
52
}
// namespace formats::common
53
54
USERVER_NAMESPACE_END
userver
formats
common
meta.hpp
Generated on
for userver by
Doxygen
1.17.0