Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
give_cvref_to.hpp
Go to the documentation of this file.
1// Copyright 2026, Toyota Motor Corporation
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_TRAITS_GIVE_CVREF_TO_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_TRAITS_GIVE_CVREF_TO_HPP_
7
8// IWYU pragma: private, include "arene/base/type_traits.hpp"
9// IWYU pragma: friend "(arene/base(?!/tests)|stdlib/include/stdlib_detail)/.*"
10
11#include "arene/base/stdlib_choice/is_lvalue_reference.hpp"
12#include "arene/base/stdlib_choice/is_rvalue_reference.hpp"
13#include "arene/base/stdlib_choice/remove_reference.hpp"
16
17namespace arene {
18namespace base {
19namespace give_cvref_to_detail {
20
21/// @brief add the reference qualification from @c From onto @c To
22/// @tparam From the type whose reference qualification is copied
23/// @tparam To the type that receives the reference qualification
24///
25/// If @c From is an lvalue reference, the result is @c To&. If @c From
26/// is an rvalue reference, the result is @c To&&. Otherwise the result
27/// is @c To unchanged. Existing qualifications on @c To are preserved.
28template <class From, class To>
29using give_reference_to = conditional_t< //
31 To&,
34 To&&,
35 To> >;
36
37} // namespace give_cvref_to_detail
38
39/// @brief Add the cv-ref qualification from one type to another
40/// @tparam From type to copy cv-ref qualification from
41/// @tparam To type to copy cv-ref qualification to
42/// @note Does not decay @c To before adding cv or ref qualification. If
43/// replacement semantics are desired, apply @c std::remove_cvref_t to @c To.
44template <class From, class To>
46 give_cvref_to_detail::give_reference_to< //
47 From,
49
50/// @brief Add the cv-ref qualification from one type to another
51/// @tparam From type to copy cv-ref qualification from
52/// @tparam To type to copy cv-ref qualification to
53/// @note Does not decay @c To before adding cv or ref qualification. If
54/// replacement semantics are desired, apply @c std::remove_cvref_t to @c To.
55template <class From, class To>
57 public:
58 /// @brief result type
60};
61
62} // namespace base
63} // namespace arene
64
65#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_TRAITS_GIVE_CVREF_TO_HPP_
Add the cv-ref qualification from one type to another.
Definition give_cvref_to.hpp:56
give_cvref_to_t< From, To > type
result type
Definition give_cvref_to.hpp:59
static constexpr value_type value
Definition integral_constant.hpp:34
Definition accumulate.hpp:37
typename static_if< B >::template then_else< T, F > conditional_t
lazily select between two types based on a boolean condition
Definition conditional.hpp:28
give_cvref_to_detail::give_reference_to< From, give_cv_to_t< std::remove_reference_t< From >, To > > give_cvref_to_t
Add the cv-ref qualification from one type to another.
Definition give_cvref_to.hpp:45
give_cv_to_detail::give_volatile_to_t< From, give_cv_to_detail::give_const_to_t< From, To > > give_cv_to_t
Add the cv qualification from one type to another.
Definition give_cv_to.hpp:67
Definition accumulate.hpp:36