Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
identity.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_FUNCTIONAL_IDENTITY_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_FUNCTIONAL_IDENTITY_HPP_
7
8// IWYU pragma: private, include "arene/base/functional.hpp"
9// IWYU pragma: friend "(arene/base(?!/tests)|stdlib/include/stdlib_detail)/.*"
10
11// parasoft-begin-suppress AUTOSAR-A16_2_2-a-2 "Arene Base aggregate headers permitted by A16-2-2 Permit #1"
12#include "arene/base/stdlib_choice/forward.hpp"
13// parasoft-end-suppress AUTOSAR-A16_2_2-a-2
14
15namespace arene {
16namespace base {
17
18// parasoft-begin-suppress AUTOSAR-A2_7_3-a "False positive: Declaration *is* preceeded by the @brief tag."
19
20/// @brief A backport of the C++20 @c std::identity function object. It returns its input unchanged.
21class identity {
22 public:
23 /// @brief Returns the input value unchanged as if forwarded via std::forward.
24 ///
25 /// @tparam T The input type.
26 /// @param value The input value.
27 /// @return T&& The forwarded input value, unchanged.
28 template <typename T>
29 constexpr auto operator()(T&& value) const noexcept -> T&& {
30 return std::forward<T>(value);
31 }
32
33 /// @brief Indicates that this function object can be used with transparent comparisons.
34 using is_transparent = void;
35};
36
37// parasoft-end-suppress AUTOSAR-A2_7_3-a
38
39} // namespace base
40} // namespace arene
41
42#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_FUNCTIONAL_IDENTITY_HPP_
A backport of the C++20 std::identity function object. It returns its input unchanged.
Definition identity.hpp:21
constexpr auto operator()(T &&value) const noexcept -> T &&
Returns the input value unchanged as if forwarded via std::forward.
Definition identity.hpp:29
Definition array_exceptions_disabled.cpp:11
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10