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"
14#include "arene/base/type_traits/conditional.hpp"
15#include "arene/base/type_traits/give_cv_to.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< //
30 std::is_lvalue_reference<From>::value,
31 To&,
32 conditional_t< //
33 std::is_rvalue_reference<From>::value,
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>
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
Definition array_exceptions_disabled.cpp:11
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10