userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
convert.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/storages/mysql/convert.hpp
4
/// @brief MySQL value conversion tag `To` and helper `DoConvert`
5
6
#
include
<
type_traits
>
7
#
include
<
utility
>
8
9
USERVER_NAMESPACE_BEGIN
10
11
namespace
storages::
mysql
::
convert
{
12
13
template
<
typename
T>
14
struct
To final {};
15
16
namespace
impl {
17
18
template
<
typename
T,
typename
DbType>
19
concept
HasConvert =
requires
(DbType&& from) { Convert(std::forward<DbType>(from),
convert
::To<T>{}); };
20
21
}
// namespace impl
22
23
template
<
typename
T,
typename
DbType>
24
T DoConvert(DbType&& from) {
25
static_assert
(
26
// TODO : better wording
27
impl::HasConvert<T, DbType>,
28
"There is no 'T Convert(From&&, storages::mysql::convert::To<T>)' in "
29
"neither namespace of 'T' or `storages::mysql::convert`"
30
);
31
32
return
Convert(std::forward<DbType>(from), To<T>{});
33
}
34
35
}
// namespace storages::mysql::convert
36
37
USERVER_NAMESPACE_END
userver
storages
mysql
convert.hpp
Generated on
for userver by
Doxygen
1.17.0