一呼百應, "one call, a hundred responses"
Loading...
Searching...
No Matches
forward_like.hpp
Go to the documentation of this file.
1#pragma once
2
17#include <type_traits>
18
19namespace std {
20
21#ifndef __cpp_lib_forward_like
22 namespace detail {
23 template <typename T, typename U>
24 using override_ref_t = conditional_t<is_rvalue_reference_v<T>, remove_reference_t<U> &&, U &>;
25
26 template <typename T, typename U>
27 using copy_const_t = conditional_t<is_const_v<remove_reference_t<T>>, U const, U>;
28
29 template <typename T, typename U>
31 }
32
51 template <typename T>
52 [[nodiscard]] constexpr
53 auto forward_like(auto&& x) noexcept -> detail::forward_like_t<T, decltype(x)> {
54 return static_cast<detail::forward_like_t<T, decltype(x)>>(x);
55 }
56#endif
57}
override_ref_t< T &&, copy_const_t< T, remove_reference_t< U > > > forward_like_t
conditional_t< is_rvalue_reference_v< T >, remove_reference_t< U > &&, U & > override_ref_t
conditional_t< is_const_v< remove_reference_t< T > >, U const, U > copy_const_t
Definition bf16.cpp:11
constexpr auto forward_like(auto &&x) noexcept -> detail::forward_like_t< T, decltype(x)>
Returns a reference to x which has similar properties to T&&.