Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
add.hpp
Go to the documentation of this file.
1// parasoft-suppress AUTOSAR-A2_8_1-a "False positive: also defines arene::base::linalg::add"
2// Copyright 2026, Toyota Motor Corporation
3//
4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_LINALG_ADD_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_LINALG_ADD_HPP_
7
8// IWYU pragma: private, include "arene/base/linalg.hpp"
9// IWYU pragma: friend "(arene/base(?!/tests)|stdlib/include/stdlib_detail)/.*"
10
11// parasoft-begin-suppress AUTOSAR-A16_2_2-a "Arene Base aggregate headers permitted by A16-2-2 Permit #1"
13#include "arene/base/functional/bind_back.hpp" // IWYU pragma: export
14#include "arene/base/linalg/elementwise_binary_transform.hpp" // IWYU pragma: export
15#include "arene/base/stdlib_choice/plus.hpp" // IWYU pragma: export
16// parasoft-end-suppress AUTOSAR-A16_2_2-a
17
18namespace arene {
19namespace base {
20namespace linalg {
21
22/// @brief Add two mdspans elementwise, writing the result into a third
23/// @tparam LhsInSpan The type of the first input span
24/// @tparam RhsInSpan The type of the second input span
25/// @tparam OutSpan The type of the output span
26/// Pass the first and second input spans as @c lhs_span and @c rhs_span, and the output span as @c out_span.
27///
28/// @pre All of @c LhsInSpan , @c RhsInSpan , and @c OutSpan must be instantiations of @c mdspan with the same @c rank
29/// @pre if @c lhs_in_span and @c out_span overlap, they must alias
30/// @pre if @c rhs_in_span and @c out_span overlap, they must alias
31/// @pre @c std::plus must be invocable with elements of the input spans, and the result must be assignable to the
32/// elements of the output span
33/// @pre All of @c lhs_span , @c rhs_span , and @c out_span must have equal extents
34// parasoft-begin-suppress CERT_CPP-DCL56-a "False positive: variable is initialized"
35// parasoft-begin-suppress AUTOSAR-M3_4_1-b "This is a per-TU reference to a global used in multiple TUs"
36ARENE_CPP14_INLINE_VARIABLE_INIT(add, arene::base::bind_back(elementwise_binary_transform, std::plus<>{}));
37// parasoft-begin-suppress AUTOSAR-M3_4_1-b
38// parasoft-end-suppress CERT_CPP-DCL56-a
39
40} // namespace linalg
41} // namespace base
42} // namespace arene
43
44#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_LINALG_ADD_HPP_
Function object for performing addition.
Definition plus.hpp:27
#define ARENE_CPP14_INLINE_VARIABLE_INIT(name,...)
Emulates C++17's inline variable declarations for an arbitrary initializer expression.
Definition cpp14_inline.hpp:95
Definition add.hpp:20
Definition accumulate.hpp:37
Definition accumulate.hpp:36