userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
forward_like.hpp
Go to the documentation of this file.
1
#pragma once
2
5
6
#include <type_traits>
7
8
#include <userver/compiler/impl/nodebug.hpp>
9
10
USERVER_NAMESPACE_BEGIN
11
12
namespace
utils
{
13
15
template
<
typename
T,
typename
U>
16
USERVER_IMPL_NODEBUG_INLINE_FUNC
inline
constexpr
auto
&&
ForwardLike
(U&& x)
noexcept
{
17
constexpr
bool
is_adding_const = std::is_const_v<std::remove_reference_t<T>>;
18
19
using
URef = std::remove_reference_t<U>;
20
using
V = std::conditional_t<is_adding_const, std::add_const_t<URef>, URef>;
21
22
if
constexpr
(std::is_lvalue_reference_v<T&&>) {
23
return
static_cast<
V&
>
(x);
24
}
else
{
25
return
static_cast<
V&&
>
(x);
26
}
27
}
28
29
}
// namespace utils
30
USERVER_NAMESPACE_END
userver
utils
forward_like.hpp
Generated on
for userver by
Doxygen
1.17.0