Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
ignore.hpp
Go to the documentation of this file.
1// parasoft-begin-suppress AUTOSAR-A2_8_1-a-2 "False positive: also defines arene::base::ignore"
2
3// Copyright 2024, Toyota Motor Corporation
4//
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6#ifndef INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_IGNORE_HPP_
7#define INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_IGNORE_HPP_
8
9// parasoft-begin-suppress CERT_CPP-DCL58-a-2 "Part of a standard library implementation"
10// parasoft-begin-suppress AUTOSAR-A17_6_1-a-2 "Part of a standard library implementation"
11
12// IWYU pragma: private, include <tuple>
13// IWYU pragma: friend "stdlib_detail/.*"
14
15#include "stdlib/include/stdlib_detail/cstddef.hpp"
16
17namespace std {
18namespace ignore_detail {
19/// @brief A class that anything can be assigned to, and which discards the assigned object
20class ignore_t {
21 public:
22 /// @brief Default constructor
23 constexpr ignore_t() = default;
24 /// @brief Default destructor
25 ~ignore_t() = default;
26
27 // parasoft-begin-suppress CERT_C-EXP37-a-3 "False positive: The rule does not mention naming all parameters"
28 /// @brief Default copy-constructor
29 constexpr ignore_t(ignore_t const&) = default;
30 // parasoft-end-suppress CERT_C-EXP37-a-3
31
32 // parasoft-begin-suppress CERT_C-EXP37-a-3 "False positive: The rule does not mention naming all parameters"
33 /// @brief Default move-constructor
34 constexpr ignore_t(ignore_t&&) = default;
35 // parasoft-end-suppress CERT_C-EXP37-a-3
36
37 // parasoft-begin-suppress CERT_C-EXP37-a-3 "False positive: The rule does not mention naming all parameters"
38 // parasoft-begin-suppress AUTOSAR-A7_1_5-a-2 "Trailing return syntax permitted by A7-1-5 Permit #1 v1.0.0"
39 /// @brief Default copy-assignment
40 constexpr auto operator=(ignore_t const&) noexcept -> ignore_t& = default;
41 // parasoft-end-suppress AUTOSAR-A7_1_5-a-2
42 // parasoft-end-suppress CERT_C-EXP37-a-3
43
44 // parasoft-begin-suppress CERT_C-EXP37-a-3 "False positive: The rule does not mention naming all parameters"
45 // parasoft-begin-suppress AUTOSAR-A7_1_5-a-2 "Trailing return syntax permitted by A7-1-5 Permit #1 v1.0.0"
46 /// @brief Default move-constructor
47 constexpr auto operator=(ignore_t&&) noexcept -> ignore_t& = default;
48 // parasoft-end-suppress AUTOSAR-A7_1_5-a-2
49 // parasoft-end-suppress CERT_C-EXP37-a-3
50
51 // parasoft-begin-suppress CERT_C-EXP37-a-3 "False positive: The rule does not mention naming all parameters"
52 /// @brief Do-nothing catch-all assignment operator
53 /// @tparam Arg The type of the argument to ignore
54 /// @return A reference to @c *this
55 template <typename Arg>
56 // NOLINTNEXTLINE(misc-unconventional-assign-operator)
57 constexpr auto operator=(Arg const&) const noexcept -> ignore_t const& {
58 return *this;
59 }
60 // parasoft-end-suppress CERT_C-EXP37-a-3
61};
62
63/// @brief An object to which anything can be assigned, which ignores the assigned value
64template <nullptr_t = nullptr>
65extern constexpr ignore_t ignore{};
66
67} // namespace ignore_detail
68
69// parasoft-begin-suppress AUTOSAR-M3_4_1-b-2 "This is a per-TU reference to a global used in multiple TUs"
70// parasoft-begin-suppress CERT_CPP-DCL56-a-3 "False positive: variable is initialized"
71/// @brief An object to which anything can be assigned, which ignores the assigned value
72static constexpr auto const& ignore = ignore_detail::ignore<>;
73// parasoft-end-suppress CERT_CPP-DCL56-a-3
74// parasoft-end-suppress AUTOSAR-M3_4_1-b-2
75
76} // namespace std
77
78#endif // INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_IGNORE_HPP_
A class that anything can be assigned to, and which discards the assigned object.
Definition ignore.hpp:20
constexpr auto operator=(ignore_t &&) noexcept -> ignore_t &=default
Default move-constructor.
constexpr ignore_t(ignore_t &&)=default
Default move-constructor.
~ignore_t()=default
Default destructor.
constexpr ignore_t(ignore_t const &)=default
Default copy-constructor.
constexpr auto operator=(Arg const &) const noexcept -> ignore_t const &
Do-nothing catch-all assignment operator.
Definition ignore.hpp:57
constexpr auto operator=(ignore_t const &) noexcept -> ignore_t &=default
Default copy-assignment.
constexpr ignore_t()=default
Default constructor.
Definition ignore.hpp:18
constexpr ignore_t ignore
An object to which anything can be assigned, which ignores the assigned value.
static constexpr auto const & ignore
An object to which anything can be assigned, which ignores the assigned value.
Definition ignore.hpp:72
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