Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
move.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_MOVE_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_MOVE_HPP_
7
8// parasoft-begin-suppress CERT_CPP-DCL58-a-2 "Part of a standard library implementation"
9// parasoft-begin-suppress AUTOSAR-A17_6_1-a-2 "Part of a standard library implementation"
10
11// IWYU pragma: private, include <utility>
12// IWYU pragma: friend "stdlib_detail/.*"
13
14#include "stdlib/include/stdlib_detail/remove_reference.hpp"
15
16namespace std {
17// parasoft-begin-suppress AUTOSAR-A8_4_6-a-2 "False positive: Value is moved"
18// parasoft-begin-suppress AUTOSAR-A8_4_5-a-2 "False positive: Value is moved"
19// parasoft-begin-suppress AUTOSAR-A12_8_4-a-2 "False positive: Value is moved"
20// parasoft-begin-suppress AUTOSAR-M3_3_2-a-2 "False positive: inline function used in multiple translation units"
21// parasoft-begin-suppress AUTOSAR-A0_1_4-a-2 "False positive: parameter is used"
22// parasoft-begin-suppress AUTOSAR-A8_4_2-a-2 "False positive: function returns a value"
23// parasoft-begin-suppress CERT_C-MSC37-a-2 "False positive: function returns a value"
24// parasoft-begin-suppress CERT_CPP-MSC52-a-2 "False positive: function returns a value"
25/// @brief Cast a value to an rvalue
26/// @tparam T The type of the value
27/// @param value The value to cast
28/// @return The supplied argument cast to an rvalue reference
29template <typename T>
30constexpr auto move(T&& value) noexcept -> remove_reference_t<T>&& {
31 return static_cast<remove_reference_t<T>&&>(value);
32}
33// parasoft-end-suppress CERT_CPP-MSC52-a-2
34// parasoft-end-suppress CERT_C-MSC37-a-2
35// parasoft-end-suppress AUTOSAR-A8_4_2-a-2
36// parasoft-end-suppress AUTOSAR-A0_1_4-a-2
37// parasoft-end-suppress AUTOSAR-M3_3_2-a-2
38// parasoft-end-suppress AUTOSAR-A12_8_4-a-2
39// parasoft-end-suppress AUTOSAR-A8_4_5-a-2
40// parasoft-end-suppress AUTOSAR-A8_4_6-a-2
41} // namespace std
42
43#endif // INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_MOVE_HPP_
constexpr auto move(T &&value) noexcept -> remove_reference_t< T > &&
Cast a value to an rvalue.
Definition move.hpp:30
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