userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
lazy_prvalue.hpp
Go to the documentation of this file.
1
#pragma once
2
5
6
#include <type_traits>
7
#include <utility>
8
9
USERVER_NAMESPACE_BEGIN
10
11
namespace
utils
{
12
19
template
<
typename
Func>
20
class
LazyPrvalue final {
21
static_assert
(!std::is_reference_v<Func>);
22
23
public
:
24
constexpr
explicit
LazyPrvalue(
const
Func& func)
25
: func_(func)
26
{}
27
28
constexpr
explicit
LazyPrvalue(Func&& func)
29
: func_(std::move(func))
30
{}
31
32
LazyPrvalue(LazyPrvalue&&) =
delete
;
33
LazyPrvalue& operator=(LazyPrvalue&&) =
delete
;
34
35
constexpr
/* implicit */
operator
std::invoke_result_t<Func&&>() && {
return
std::move(func_)(); }
36
37
private
:
38
[[no_unique_address]] Func func_;
39
};
40
41
}
// namespace utils
42
43
USERVER_NAMESPACE_END
userver
utils
lazy_prvalue.hpp
Generated on
for userver by
Doxygen
1.17.0