Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
add_lvalue_reference.hpp
Go to the documentation of this file.
1
// Copyright 2024, Toyota Motor Corporation
2
//
3
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5
#
ifndef
INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_ADD_LVALUE_REFERENCE_HPP_
6
#
define
INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_ADD_LVALUE_REFERENCE_HPP_
7
8
#
include
"arene/base/constraints.hpp"
9
10
// parasoft-begin-suppress CERT_CPP-DCL58-a-2 "Part of a standard library implementation"
11
// parasoft-begin-suppress AUTOSAR-A17_6_1-a-2 "Part of a standard library implementation"
12
13
// IWYU pragma: private, include <type_traits>
14
// IWYU pragma: friend "stdlib_detail/.*"
15
16
namespace
std
{
17
18
// parasoft-begin-suppress AUTOSAR-A2_7_3-a "False positive: all declarations
19
// and typedefs *are* preceded by a comment with @brief"
20
21
namespace
add_lvalue_reference_detail
{
22
23
/// @brief Base case when @c Type is not referenceable.
24
/// @tparam Type The type to add an lvalue reference to
25
template
<
typename
Type,
class
=
arene
::
base
::
constraints
<>>
26
class
add_lvalue_reference
{
27
public
:
28
/// @brief The resulting type
29
using
type = Type;
30
};
31
32
/// @brief Add an lvalue reference onto @c Type
33
/// @tparam Type The type to add an lvalue reference to
34
template
<
typename
Type
>
35
class
add_lvalue_reference
<
Type
,
arene
::
base
::
constraints
<
Type
&>> {
36
public
:
37
/// @brief The resulting type
38
using
type
=
Type
&;
39
};
40
41
}
// namespace add_lvalue_reference_detail
42
43
/// @brief Add an lvalue reference onto @c Type
44
/// @tparam Type The type to add an lvalue reference to
45
///
46
/// @c add_lvalue_reference works with both referenceable and non-referenceable types. Referenceable types are types in
47
/// one of three categories:
48
/// 1. object types
49
/// 2. function types that are not cv-ref qualified.
50
/// 3. reference types
51
///
52
/// For category 3, this should follow reference collapsing rules.
53
///
54
/// Any type not in one of these three categories is a "non-referenceable" type. For example, void.
55
/// For non-referenceable types, @c add_lvalue_reference will return back the input type.
56
///
57
template
<
typename
Type
>
58
using
add_lvalue_reference
=
add_lvalue_reference_detail
::
add_lvalue_reference
<
Type
>;
59
60
/// @brief Add an lvalue reference onto @c Type
61
/// @tparam Type The type to add an lvalue reference to
62
template
<
typename
Type
>
63
using
add_lvalue_reference_t
=
typename
add_lvalue_reference
<
Type
>::
type
;
64
65
// parasoft-end-suppress AUTOSAR-A2_7_3-a
66
67
}
// namespace std
68
69
#
endif
// INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_ADD_LVALUE_REFERENCE_HPP_
std::add_lvalue_reference_detail::add_lvalue_reference
Base case when Type is not referenceable.
Definition
add_lvalue_reference.hpp:26
std::add_lvalue_reference_detail
Definition
add_lvalue_reference.hpp:21
std::hash<::arene::base::result< void, E > >::operator()
constexpr auto operator()(::arene::base::result< void, E > const &value) const noexcept(noexcept(hash< E >{}(std::declval< E const & >()))) -> std::size_t
Calculate the hash of a result.
Definition
result.hpp:1827
stdlib
include
stdlib_detail
add_lvalue_reference.hpp
Generated by
1.13.2