RESTinio
Loading...
Searching...
No Matches
restinio
utils
tagged_scalar.hpp
Go to the documentation of this file.
1
/*
2
* RESTinio
3
*/
4
5
/*!
6
* @file
7
* @brief Helper template for defining tagged scalar types.
8
*
9
* @since v.0.6.12
10
*/
11
12
#
pragma
once
13
14
#
include
<
restinio
/
compiler_features
.
hpp
>
15
16
#
include
<
type_traits
>
17
18
namespace
restinio
19
{
20
21
namespace
utils
22
{
23
24
//
25
// tagged_scalar_t
26
//
27
/*!
28
* @brief Helper template for defining tagged scalar types.
29
*
30
* Usage example:
31
* @code
32
* struct max_parallel_connections_tag {};
33
* using max_parallel_connections_t = tagged_scalar_t<
34
* std::size_t, max_parallel_connections_tag >;
35
*
36
* struct max_active_accepts_tag {};
37
* using max_active_accepts_t = tagged_scalar_t<
38
* std::size_t, max_active_accepts_tag >;
39
*
40
* class limiter_t
41
* {
42
* public:
43
* limiter_t(
44
* max_parallel_connections_t parallel_connections,
45
* max_active_accepts_t active_accepts);
46
* ...
47
* };
48
* @endcode
49
*
50
* @since v.0.6.12
51
*/
52
template
<
typename
Scalar,
typename
Tag >
53
class
tagged_scalar_t
54
{
55
static_assert
( std::is_scalar<Scalar>::value,
56
"Scalar is expected to be scalar type"
);
57
58
Scalar
m_value
;
59
60
public
:
61
constexpr
explicit
tagged_scalar_t
( Scalar value )
noexcept
62
:
m_value
{ value }
63
{}
64
65
[[
nodiscard
]]
66
constexpr
Scalar
67
value
()
const
noexcept
{
return
m_value
; }
68
};
69
70
}
/* namespace utils */
71
72
}
/* namespace restinio */
restinio::utils::tagged_scalar_t
Helper template for defining tagged scalar types.
Definition
tagged_scalar.hpp:54
restinio::utils::tagged_scalar_t::m_value
Scalar m_value
Definition
tagged_scalar.hpp:58
restinio::utils::tagged_scalar_t::tagged_scalar_t
constexpr tagged_scalar_t(Scalar value) noexcept
Definition
tagged_scalar.hpp:61
restinio::utils::tagged_scalar_t::value
constexpr Scalar value() const noexcept
Definition
tagged_scalar.hpp:67
restinio::utils
Definition
from_string_details.ipp:5
restinio
Definition
sendfile_operation_default.ipp:12
Generated by
1.14.0