userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
meta_containers.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/dump/meta_containers.hpp
4
/// @brief Dump serialization customization points for STL containers
5
6
#
include
<
iterator
>
7
#
include
<
map
>
8
#
include
<
set
>
9
#
include
<
type_traits
>
10
#
include
<
unordered_map
>
11
#
include
<
unordered_set
>
12
#
include
<
utility
>
13
#
include
<
vector
>
14
15
#
include
<
userver
/
dump
/
meta
.
hpp
>
16
#
include
<
userver
/
utils
/
meta
.
hpp
>
17
18
USERVER_NAMESPACE_BEGIN
19
20
namespace
dump
{
21
22
/// @{
23
/// Customization point: insert an element into a container
24
template
<
typename
T,
typename
Alloc>
25
void
Insert
(std::vector<T, Alloc>& cont, T&& elem) {
26
cont.push_back(std::forward<T>(elem));
27
}
28
29
template
<
typename
K,
typename
V,
typename
Comp,
typename
Alloc>
30
void
Insert(std::map<K, V, Comp, Alloc>& cont, std::pair<
const
K, V>&& elem) {
31
cont.insert(std::move(elem));
32
}
33
34
template
<
typename
K,
typename
V,
typename
Hash,
typename
Eq,
typename
Alloc>
35
void
Insert(std::unordered_map<K, V, Hash, Eq, Alloc>& cont, std::pair<
const
K, V>&& elem) {
36
cont.insert(std::move(elem));
37
}
38
39
template
<
typename
T,
typename
Comp,
typename
Alloc>
40
void
Insert(std::set<T, Comp, Alloc>& cont, T&& elem) {
41
cont.insert(std::forward<T>(elem));
42
}
43
44
template
<
typename
T,
typename
Hash,
typename
Eq,
typename
Alloc>
45
void
Insert(std::unordered_set<T, Hash, Eq, Alloc>& cont, T&& elem) {
46
cont.insert(std::forward<T>(elem));
47
}
48
/// @}
49
50
/// Check if a range is a container
51
template
<
typename
T>
52
concept
IsContainer
=
53
meta::
kIsRange
<T> && std::is_default_constructible_v<T> && meta::
kIsSizable
<T> &&
54
requires
(T& t, meta::
RangeValueType
<T>&& v) {
dump
::Insert(t, std::move(v)); };
55
56
}
// namespace dump
57
58
USERVER_NAMESPACE_END
userver
dump
meta_containers.hpp
Generated on
for userver by
Doxygen
1.17.0