Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
consume_values.hpp
Go to the documentation of this file.
1// parasoft-begin-suppress AUTOSAR-A2_8_1-a-2 "False positive: also defines arene::base::consume_values"
2
3// Copyright 2024, Toyota Motor Corporation
4//
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_MANIPULATION_CONSUME_VALUES_HPP_
7#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_MANIPULATION_CONSUME_VALUES_HPP_
8
9// parasoft-begin-suppress AUTOSAR-A7_1_5-a-2 "Trailing return syntax permitted by A7-1-5 Permit #1 v1.0.0"
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/constraints/constraints.hpp"
13#include "arene/base/stdlib_choice/enable_if.hpp"
14#include "arene/base/stdlib_choice/initializer_list.hpp"
15#include "arene/base/stdlib_choice/is_same.hpp"
16#include "arene/base/stdlib_choice/remove_cv.hpp"
17#include "arene/base/stdlib_choice/remove_reference.hpp"
18#include "arene/base/type_traits/remove_cvref.hpp"
19// parasoft-end-suppress AUTOSAR-A16_2_2-a-2
20
21namespace arene {
22namespace base {
23
24namespace consume_values_detail {
25
26/// @brief Type implicit conversions from anything as a nop. Used as a catch-all consumer for @c consume_values
27class anything {
28 public:
29 /// @brief Can default construct
30 constexpr anything() noexcept = default;
31
32 // parasoft-begin-suppress AUTOSAR-A13_3_1-a-2 "False positive: Constrained via SFINAE"
33 /// @brief Default copy constructor
34 /// @param other The source
35 constexpr anything(anything const& other) noexcept = default;
36 // parasoft-end-suppress AUTOSAR-A13_3_1-a-2
37 /// @brief Default move constructor
38 /// @param other The source
39 constexpr anything(anything&& other) noexcept = default;
40
41 /// @brief Default copy assignment
42 /// @param other The source
43 /// @return @c *this
44 constexpr auto operator=(anything const& other) noexcept -> anything& = default;
45 /// @brief Default move assignment
46 /// @param other The source
47 /// @return @c *this
48 constexpr auto operator=(anything&& other) noexcept -> anything& = default;
49
50 /// @brief default destructor
51 ~anything() = default;
52
53 /// @brief Can construct from anything.
54 /// @tparam Arg the type of the source
55 template <typename Arg, constraints<std::enable_if_t<!std::is_same<anything, remove_cvref_t<Arg>>::value>> = nullptr>
56 // This constructor works as a copy and move constructor too, but that's OK
57 // because the class has no content or behaviour
58 // AUTOSAR A12-1-4 exception: The intent of this object is to allow implicit
59 // conversions from all values, and discard the values
60 // NOLINTNEXTLINE(google-explicit-constructor,hicpp-explicit-conversions,bugprone-forwarding-reference-overload)
61 constexpr anything(Arg&&) noexcept {}
62};
63
64} // namespace consume_values_detail
65
66// parasoft-begin-suppress AUTOSAR-M0_1_8-b-2 "The intent of this function is that it does nothing"
67/// @brief Consume a list of values and discard them.
68/// Must be called with an extra pair of braces around the expressions to be consumed:
69/// <c>consume_values({e1,e2,...})</c>. The use of @c std::initializer_list ensures the expressions to be consumed are
70/// evaluated in left-to-right sequential order.
71/// @pre The supplied expressions must have a non-<c>void</c> type. @c void_ can be used as the return type if it would
72/// otherwise be @c void
73inline constexpr void consume_values(std::initializer_list<consume_values_detail::anything> const&) noexcept {}
74// parasoft-end-suppress AUTOSAR-M0_1_8-b-2
75
76} // namespace base
77} // namespace arene
78
79#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_MANIPULATION_CONSUME_VALUES_HPP_
Definition array_exceptions_disabled.cpp:11
constexpr void consume_values(std::initializer_list< consume_values_detail::anything > const &) noexcept
Consume a list of values and discard them. Must be called with an extra pair of braces around the exp...
Definition consume_values.hpp:73
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10