Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
function.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_ARENE_BASE_INLINE_CONTAINER_FUNCTION_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_INLINE_CONTAINER_FUNCTION_HPP_
7
8// IWYU pragma: private, include "arene/base/functional.hpp"
9
10// parasoft-begin-suppress AUTOSAR-A16_2_2-a-2 "Arene Base aggregate headers permitted by A16-2-2 Permit #1"
11#include "arene/base/array/array.hpp"
12#include "arene/base/byte/byte.hpp"
13#include "arene/base/constraints/constraints.hpp"
14#include "arene/base/contracts/contract.hpp"
15#include "arene/base/memory/construct_at.hpp"
16#include "arene/base/stdlib_choice/cstddef.hpp"
17#include "arene/base/stdlib_choice/decay.hpp"
18#include "arene/base/stdlib_choice/enable_if.hpp"
19#include "arene/base/stdlib_choice/forward.hpp"
20#include "arene/base/stdlib_choice/is_base_of.hpp"
21#include "arene/base/stdlib_choice/is_move_constructible.hpp"
22#include "arene/base/stdlib_choice/is_same.hpp"
23#include "arene/base/stdlib_choice/move.hpp"
24#include "arene/base/type_traits/conditional.hpp"
25#include "arene/base/type_traits/is_invocable.hpp"
26// parasoft-end-suppress AUTOSAR-A16_2_2-a-2
27
28// parasoft-begin-suppress CERT_C-EXP37-a-3 "False positive: The rule does not mention naming all parameters"
29// parasoft-begin-suppress AUTOSAR-M2_10_1-a-2 "Similar names permitted by M2-10-1 Permit #1"
30// parasoft-begin-suppress AUTOSAR-A15_4_3-a-2 "False positive: This file is the only declaration of these functions"
31
32namespace arene {
33namespace base {
34
35// parasoft-begin-suppress AUTOSAR-A5_1_1-a "False positive: The literal here is a scalar for a multiply."
36/// @brief The default size of the buffer used for @c inline_function .
37static constexpr std::size_t default_inline_function_size{4U * sizeof(void*)};
38// parasoft-end-suppress AUTOSAR-A5_1_1-a
39
40/// @brief A function wrapper akin to @c std::function that always stores the wrapped invocable internally.
41/// @tparam Signature The signature of the function call operator.
42/// @tparam BufferSize The size of the internal buffer. It defaults to 4 times the size of a pointer.
43/// @tparam IsNoexcept If @c true , the function will have a @c noexcept qualified call operator. Otherwise, it will
44/// not.
45/// @note If the signature is const-qualified (e.g. <c> int (int,double) const</c> ) then the function call operator for
46/// this class will also be const-qualified. If the signature is *not* const-qualified, then only non-const objects will
47/// be invocable.
48template <typename Signature, std::size_t BufferSize = default_inline_function_size, bool IsNoexcept = false>
49class inline_function;
50
51/// @brief A function wrapper to a noexcept-qualified invocable akin to @c std::function that always stores the wrapped
52/// invocable internally.
53/// @tparam Signature The signature of the function call operator.
54/// @tparam BufferSize The size of the internal buffer. It defaults to 4 times the size of a pointer.
55/// @note If the signature is const-qualified (e.g. <c> int (int,double) const</c> ) then the function call operator for
56/// this class will also be const-qualified. If the signature is *not* const-qualified, then only non-const objects will
57/// be invocable.
58template <typename Signature, std::size_t BufferSize = default_inline_function_size>
59using noexcept_inline_function = inline_function<Signature, BufferSize, true>;
60
61namespace inline_function_detail {
62
63// parasoft-begin-suppress AUTOSAR-A12_1_5-a-2 "False positive: delegating constructors are used"
64/// @brief Base class for @c inline_function that provides the implementation details
65/// @tparam BufferSize The size of the internal buffer.
66/// @tparam IsConst Should this function have a const-qualified function call operator?
67/// @tparam IsNoexcept Should this function require a noexcept-qualified callable?
68/// @tparam ReturnType The return type of the function call operator
69/// @tparam Args The argument types of the function call operator
70template <std::size_t BufferSize, bool IsConst, bool IsNoexcept, typename ReturnType, typename... Args>
71class inline_function_base {
72 /// @brief The type of the @c self argument for the @c invoke function
73 using invoke_self_type = conditional_t<IsConst, inline_function_base const&, inline_function_base&>;
74
75 /// @brief The function signature of the @c invoke function
76 using invoke_func_type = ReturnType(invoke_self_type self, Args&&... args);
77
78 /// @brief A table of operations that can be applied to the wrapped invocable.
79 /// The members are @c const so that the compiler can see the values don't change: there should be exactly one of
80 /// these objects per type of callable.
81 struct operation_functions {
82 /// @brief A pointer to a function that destroys the wrapped invocable
83 // NOLINTNEXTLINE(cppcoreguidelines-avoid-const-or-ref-data-members)
84 void (*const destroy)(inline_function_base& self) noexcept;
85 /// @brief A pointer to a function that moves the wrapped invocable from @c source
86 /// to @c target, leaving @c source empty
87 // NOLINTNEXTLINE(cppcoreguidelines-avoid-const-or-ref-data-members)
88 void (*const move)(inline_function_base& target, inline_function_base& source) noexcept;
89 /// @brief A pointer to a function that invokes the wrapped invocable with the
90 /// supplied arguments
91 // NOLINTNEXTLINE(cppcoreguidelines-avoid-const-or-ref-data-members)
92 invoke_func_type* const invoke;
93 };
94
95 /// @brief Destroy a wrapped invocable.
96 /// @tparam T The type of the wrapped invocable
97 /// @param self The wrapper object that holds the invocable
98 template <typename T>
99 static void do_destroy(inline_function_base& self) noexcept {
100 // parasoft-begin-suppress AUTOSAR-M0_1_3-b-2 "False positive: The variable is used on the next line"
101 T& wrapped_invocable{*self.template get_ptr<T>()};
102 // parasoft-end-suppress AUTOSAR-M0_1_3-b-2
103 wrapped_invocable.~T();
104 self.operations_ = nullptr;
105 }
106
107 /// @brief Move a wrapped invocable from one wrapper to another and leaves the source
108 /// empty.
109 /// @tparam T The type of the wrapped invocable
110 /// @param source The wrapper object that holds the source invocable
111 /// @param target The wrapper object that will hold the moved invocable
112 template <typename T>
113 static void do_move(inline_function_base& target, inline_function_base& source) noexcept {
114 target.construct_from(std::move(*source.template get_ptr<T>()));
115 target.operations_ = source.operations_;
116 do_destroy<T>(source);
117 }
118
119 /// @brief Invoke the wrapped invocable as a const or non-const object as applicable,
120 /// with the supplied arguments.
121 /// @tparam T The type of the wrapped invocable
122 /// @param self The wrapper object that holds the invocable
123 /// @param args The function call arguments
124 /// @return The result of the invocation
125 template <typename T>
126 static auto do_invoke(invoke_self_type self, Args&&... args) -> ReturnType {
127 auto& wrapped_invocable = *self.template get_ptr<T>();
128 // parasoft-begin-suppress AUTOSAR-A18_9_2-a-2 "Use of 'forward' here ensures rvalues are correctly moved"
129 return static_cast<ReturnType>(wrapped_invocable(std::forward<Args>(args)...));
130 // parasoft-end-suppress AUTOSAR-A18_9_2-a-2
131 }
132
133 /// @brief The table of function pointers for a given invocable type
134 /// @tparam T The type of the wrapped invocable
135 template <typename T>
136 static constexpr operation_functions call_table{&do_destroy<T>, &do_move<T>, &do_invoke<T>};
137
138 protected:
139 /// @brief Trait to determine if a functor is invocable with matching constness, noexcept, return and arguments.
140 /// @tparam T the function type to test.
141 /// @return If @c IsNoexcept , then equivalent to @c is_nothrow_invocable_r_v<ReturnType,T,Args...> . Otherwise,
142 /// equivalent to @c is_invocable_r_v<ReturnType,T,Args...>
143 template <typename T>
144 static constexpr bool
145 is_invocable_n_r_v{IsNoexcept ? ::arene::base::is_nothrow_invocable_r_v<ReturnType, T, Args...> : ::arene::base::is_invocable_r_v<ReturnType, T, Args...>};
146
147 public:
148 /// @brief Default construct with no wrapped invocable
149 inline_function_base() noexcept
150 : buffer_{},
151 operations_{nullptr} {}
152
153 /// @brief Not copyable
154 inline_function_base(inline_function_base const&) = delete;
155 /// @brief Not copyable
156 auto operator=(inline_function_base const&) -> inline_function_base& = delete;
157
158 /// @brief Construct with a wrapped invocable
159 /// @tparam T The type of the wrapped invocable
160 /// @param invocable The invocable to wrap
161 /// @pre The supplied invocable must be invocable with @c Args, with a return
162 /// type that can be converted to @c ReturnType, both as a const and non-const
163 /// object. The invocable must also be nothrow-move-constructible, and must
164 /// fit in the buffer.
165 template <
166 typename T,
167 constraints<
168 std::enable_if_t<(sizeof(std::decay_t<T>) <= BufferSize)>,
169 std::enable_if_t<std::is_nothrow_move_constructible<std::decay_t<T>>::value>,
170 std::enable_if_t<is_invocable_n_r_v<conditional_t<IsConst, std::decay_t<T> const, std::decay_t<T>>>>> =
171 nullptr>
172 // NOLINTNEXTLINE(bugprone-forwarding-reference-overload,google-explicit-constructor,hicpp-explicit-conversions)
173 inline_function_base(T&& invocable) noexcept
174 : buffer_{},
175 operations_(&call_table<std::decay_t<T>>) {
176 construct_from(std::forward<T>(invocable));
177 }
178
179 /// @brief Deleted constructor for an invocable that is too large for the buffer. The
180 /// template parameter and parameter names are specified to make the error
181 /// message clearer.
182 /// @tparam InvocableTooBigForBuffer The type of the supplied invocable
183 /// @param buffer_too_small The supplied invocable
184 template <
185 typename InvocableTooBigForBuffer,
186 constraints<
187 std::enable_if_t<(sizeof(std::decay_t<InvocableTooBigForBuffer>) > BufferSize)>,
188 std::enable_if_t<!std::is_base_of<inline_function_base, std::decay_t<InvocableTooBigForBuffer>>::value>> =
189 nullptr>
190 // NOLINTNEXTLINE(bugprone-forwarding-reference-overload,google-explicit-constructor,hicpp-explicit-conversions)
191 inline_function_base(InvocableTooBigForBuffer&& buffer_too_small) = delete;
192
193 /// @brief Assign from an invocable
194 /// @tparam T The type of the invocable
195 /// @param invocable The invocable to wrap
196 /// @pre The supplied invocable must be invocable with @c Args, with a return
197 /// type that can be converted to @c ReturnType, both as a const and non-const
198 /// object. The invocable must also be nothrow-move-constructible, and must
199 /// fit in the buffer.
200 template <
201 typename T,
202 constraints<
203 std::enable_if_t<(sizeof(std::decay_t<T>) <= BufferSize)>,
204 std::enable_if_t<std::is_nothrow_move_constructible<std::decay_t<T>>::value>,
205 std::enable_if_t<is_invocable_n_r_v<conditional_t<IsConst, std::decay_t<T> const, std::decay_t<T>>>>> =
206 nullptr>
207 void assign_from(T&& invocable) noexcept {
208 destroy();
209 operations_ = &call_table<std::decay_t<T>>;
210 construct_from(std::forward<T>(invocable));
211 }
212
213 /// @brief Construct from an invocable
214 /// @tparam T The type of the invocable
215 /// @param invocable The invocable to wrap
216 /// @pre The supplied invocable must be invocable with @c Args, with a return
217 /// type that can be converted to @c ReturnType, both as a const and non-const
218 /// object. The invocable must also be nothrow-move-constructible, and must
219 /// fit in the buffer.
220 template <
221 typename T,
222 constraints<
223 std::enable_if_t<(sizeof(std::decay_t<T>) <= BufferSize)>,
224 std::enable_if_t<std::is_nothrow_move_constructible<std::decay_t<T>>::value>,
225 std::enable_if_t<is_invocable_n_r_v<conditional_t<IsConst, std::decay_t<T> const, std::decay_t<T>>>>> =
226 nullptr>
227 void construct_from(T&& invocable) noexcept {
228 construct_at(get_ptr<std::decay_t<T>>(), std::forward<T>(invocable));
229 }
230
231 /// @brief Destroy the wrapped invocable
232 ~inline_function_base() { destroy(); }
233
234 /// @brief Is this function initialized with an invocable?
235 /// @return @c true if the object is initialized, @c false otherwise
236 auto is_initialized() const noexcept -> bool { return operations_ != nullptr; }
237
238 /// @brief Get a pointer to the invoke function
239 /// @return A pointer to the function
240 auto get_invoke() const noexcept -> invoke_func_type* {
241 ARENE_PRECONDITION(is_initialized());
242 return operations_->invoke;
243 }
244
245 /// @brief Check if there is a wrapped invocable
246 /// @return true If there is a wrapped invocable.
247 /// @return false Otherwise.
248 explicit operator bool() const noexcept { return is_initialized(); }
249
250 protected:
251 // parasoft-begin-suppress AUTOSAR-A8_4_6-a-2 "False positive: The data is moved via the 'move_from' function"
252 // parasoft-begin-suppress AUTOSAR-A8_4_5-a-2 "False positive: The data is moved via the 'move_from' function"
253 // parasoft-begin-suppress AUTOSAR-A12_8_4-a-2 "False positive: The data is moved via the 'move_from' function"
254 /// @brief Construct a new object that takes ownership of the invocable held by the
255 /// source. Leaves the source without an invocable.
256 /// @param other The object to move from
257 inline_function_base(inline_function_base&& other) noexcept
258 : inline_function_base{} {
259 move_from(other);
260 }
261 // parasoft-end-suppress AUTOSAR-A8_4_6-a-2
262 // parasoft-end-suppress AUTOSAR-A8_4_5-a-2
263 // parasoft-end-suppress AUTOSAR-A12_8_4-a-2
264
265 // parasoft-begin-suppress AUTOSAR-A8_4_6-a-2 "False positive: The data is moved via the 'move_from' function"
266 // parasoft-begin-suppress AUTOSAR-A8_4_5-a-2 "False positive: The data is moved via the 'move_from' function"
267 // parasoft-begin-suppress AUTOSAR-A12_8_4-a-2 "False positive: this is not a move constructor"
268 /// @brief Transfer ownership of an invocable from another object. Leaves the source
269 /// without an invocable.
270 /// @param other The object to move from
271 /// @return A reference to @c *this
272 auto operator=(inline_function_base&& other) noexcept -> inline_function_base& {
273 if (&other != this) {
274 destroy();
275 move_from(other);
276 }
277 return *this;
278 }
279 // parasoft-end-suppress AUTOSAR-A8_4_6-a-2
280 // parasoft-end-suppress AUTOSAR-A8_4_5-a-2
281 // parasoft-end-suppress AUTOSAR-A12_8_4-a-2
282
283 private:
284 /// @brief Destroy the invocable if there is one
285 void destroy() noexcept {
286 if (is_initialized()) {
287 operations_->destroy(*this);
288 }
289 }
290
291 /// @brief Transfer ownership of an invocable from another object, if it has one
292 /// @param other The object to move from
293 void move_from(inline_function_base& other) {
294 if (other.is_initialized()) {
295 other.operations_->move(*this, other);
296 }
297 }
298
299 /// @brief Get a pointer to the wrapped invocable or its storage (if not yet
300 /// constructed)
301 /// @tparam T The type of the wrapped invocable
302 /// @return A pointer to the object or storage
303 template <typename T>
304 auto get_ptr() noexcept -> T* {
305 return static_cast<T*>(static_cast<void*>(buffer_.data()));
306 }
307
308 /// @brief Get a const pointer to the wrapped invocable
309 /// @tparam T The type of the wrapped invocable
310 /// @return A pointer to the object
311 template <typename T>
312 auto get_ptr() const noexcept -> T const* {
313 return static_cast<T const*>(static_cast<void const*>(buffer_.data()));
314 }
315
316 /// @brief The storage for the wrapped invocable
317 alignas(std::max_align_t) array<byte, BufferSize> buffer_;
318
319 /// @brief The pointer to the operation table
320 operation_functions const* operations_;
321};
322// parasoft-end-suppress AUTOSAR-A12_1_5-a-2
323
324/// @brief Out-of-line definition for the operation table
325/// @tparam ReturnType The return type of the function call operator
326/// @tparam Args The argument types of the function call operator
327/// @tparam BufferSize The size of the internal buffer.
328/// @tparam T The type of the wrapped invocable
329template <std::size_t BufferSize, bool IsConst, bool IsNoexcept, typename ReturnType, typename... Args>
330template <typename T>
331constexpr typename inline_function_base<BufferSize, IsConst, IsNoexcept, ReturnType, Args...>::operation_functions
332 inline_function_base<BufferSize, IsConst, IsNoexcept, ReturnType, Args...>::call_table;
333
334} // namespace inline_function_detail
335
336/// @brief A function wrapper akin to @c std::function that always stores the
337/// wrapped invocable internally. This specialization is for where
338/// the function type is not @c const qualified
339/// @tparam ReturnType The return type of the function call operator
340/// @tparam Args The argument types of the function call operator
341/// @tparam BufferSize The size of the internal buffer.
342/// @tparam IsNoexcept If @c true , the function will have a @c noexcept qualified call operator. Otherwise, it will
343/// not.
344template <typename ReturnType, typename... Args, std::size_t BufferSize, bool IsNoexcept>
345class inline_function<ReturnType(Args...), BufferSize, IsNoexcept>
346 : inline_function_detail::inline_function_base<BufferSize, false, IsNoexcept, ReturnType, Args...> {
347 /// @brief The type of the base class
348 using base_class = inline_function_detail::inline_function_base<BufferSize, false, IsNoexcept, ReturnType, Args...>;
349
350 public:
351 /// @brief Inherit the base class converting constructors
352 using base_class::base_class;
353
354 /// @brief Default construct with no stored invocable
355 inline_function() noexcept = default;
356
357 /// @brief Transfer ownership of an invocable from another object. Leaves the source
358 /// without an invocable.
359 /// @param other The object to move from
360 inline_function(inline_function&& other) noexcept = default;
361
362 /// @brief Transfer ownership of an invocable from another object. Leaves the source
363 /// without an invocable.
364 /// @param other The object to move from
365 /// @return A reference to @c *this
366 auto operator=(inline_function&& other) noexcept -> inline_function& = default;
367
368 /// @brief Assign from a wrapped invocable
369 /// @tparam T The type of the wrapped invocable
370 /// @param invocable The invocable to wrap
371 /// @return A reference to @c *this
372 /// @pre The supplied invocable must be invocable with @c Args, with a return
373 /// type that can be converted to @c ReturnType, both as a const and non-const
374 /// object. The invocable must also be nothrow-move-constructible, and must
375 /// fit in the buffer.
376 template <
377 typename T,
378 constraints<
379 std::enable_if_t<(sizeof(std::decay_t<T>) <= BufferSize)>,
380 std::enable_if_t<std::is_nothrow_move_constructible<std::decay_t<T>>::value>,
381 std::enable_if_t<base_class::template is_invocable_n_r_v<std::decay_t<T>>>> = nullptr>
382 auto operator=(T&& invocable) noexcept -> inline_function& {
383 this->assign_from(std::forward<T>(invocable));
384 return *this;
385 }
386
387 /// @brief Deleted assignment operator for an invocable that is too large for the
388 /// buffer. The template parameter and parameter names are specified to make
389 /// the error message clearer.
390 /// @tparam InvocableTooBigForBuffer The type of the supplied invocable
391 /// @param buffer_too_small The supplied invocable
392 template <
393 typename InvocableTooBigForBuffer,
394 constraints<
395 std::enable_if_t<(sizeof(std::decay_t<InvocableTooBigForBuffer>) > BufferSize)>,
396 std::enable_if_t<!std::is_same<inline_function, std::decay_t<InvocableTooBigForBuffer>>::value>> = nullptr>
397 auto operator=(InvocableTooBigForBuffer&& buffer_too_small) -> inline_function& = delete;
398
399 /// @brief Not copyable
400 inline_function(inline_function const&) = delete;
401 /// @brief Not copyable
402 auto operator=(inline_function const&) -> inline_function& = delete;
403
404 /// @brief Destroy the wrapped invocable
405 ~inline_function() = default;
406
407 /// @brief Inherit the base class boolean conversion operator
408 using base_class::operator bool;
409
410 /// @brief Invoke the wrapped invocable as a non-const object, with the supplied
411 /// arguments
412 /// @param args The arguments for the call
413 /// @return The value returned from the call
414 auto operator()(Args... args) noexcept(IsNoexcept) -> ReturnType {
415 ARENE_PRECONDITION(this->is_initialized());
416 // parasoft-begin-suppress AUTOSAR-A18_9_2-a-2 "Use of 'forward' here ensures rvalues are correctly moved"
417 return this->get_invoke()(*this, std::forward<Args>(args)...);
418 // parasoft-end-suppress AUTOSAR-A18_9_2-a-2
419 }
420};
421
422/// @brief A function wrapper akin to @c std::function that always stores the
423/// wrapped invocable internally. This specialization is for where the
424/// function type is @c const qualified
425/// @tparam ReturnType The return type of the function call operator
426/// @tparam Args The argument types of the function call operator
427/// @tparam BufferSize The size of the internal buffer.
428/// @tparam IsNoexcept If @c true , the function will have a @c noexcept qualified call operator. Otherwise, it will
429/// not.
430template <typename ReturnType, typename... Args, std::size_t BufferSize, bool IsNoexcept>
431class inline_function<ReturnType(Args...) const, BufferSize, IsNoexcept>
432 : inline_function_detail::inline_function_base<BufferSize, true, IsNoexcept, ReturnType, Args...> {
433 /// @brief Internal type alias for the base class
434 using base_class = inline_function_detail::inline_function_base<BufferSize, true, IsNoexcept, ReturnType, Args...>;
435
436 public:
437 /// @brief Inherit the base class converting constructors
438 using base_class::base_class;
439
440 /// @brief Default construct with no stored invocable
441 inline_function() noexcept = default;
442
443 /// @brief Transfer ownership of an invocable from another object. Leaves the source
444 /// without an invocable.
445 /// @param other The object to move from
446 inline_function(inline_function&& other) noexcept = default;
447
448 /// @brief Transfer ownership of an invocable from another object. Leaves the source
449 /// without an invocable.
450 /// @param other The object to move from
451 /// @return A reference to @c *this
452 auto operator=(inline_function&& other) noexcept -> inline_function& = default;
453
454 /// @brief Assign from a wrapped invocable
455 /// @tparam T The type of the wrapped invocable
456 /// @param invocable The invocable to wrap
457 /// @return A reference to @c *this
458 /// @pre The supplied invocable must be invocable with @c Args, with a return
459 /// type that can be converted to @c ReturnType, both as a const and non-const
460 /// object. The invocable must also be nothrow-move-constructible, and must
461 /// fit in the buffer.
462 template <
463 typename T,
464 constraints<
465 std::enable_if_t<(sizeof(std::decay_t<T>) <= BufferSize)>,
466 std::enable_if_t<std::is_nothrow_move_constructible<std::decay_t<T>>::value>,
467 std::enable_if_t<base_class::template is_invocable_n_r_v<std::decay_t<T> const>>> = nullptr>
468 auto operator=(T&& invocable) noexcept -> inline_function& {
469 this->assign_from(std::forward<T>(invocable));
470 return *this;
471 }
472
473 /// @brief Deleted assignment operator for an invocable that is too large for the
474 /// buffer. The template parameter and parameter names are specified to make
475 /// the error message clearer.
476 /// @tparam InvocableTooBigForBuffer The type of the supplied invocable
477 /// @param buffer_too_small The supplied invocable
478 template <
479 typename InvocableTooBigForBuffer,
480 constraints<
481 std::enable_if_t<(sizeof(std::decay_t<InvocableTooBigForBuffer>) > BufferSize)>,
482 std::enable_if_t<!std::is_same<inline_function, std::decay_t<InvocableTooBigForBuffer>>::value>> = nullptr>
483 auto operator=(InvocableTooBigForBuffer&& buffer_too_small) -> inline_function& = delete;
484
485 /// @brief Not copyable
486 inline_function(inline_function const&) = delete;
487 /// @brief Not copyable
488 auto operator=(inline_function const&) -> inline_function& = delete;
489
490 /// @brief Destroy the wrapped invocable
491 ~inline_function() = default;
492
493 /// @brief Inherit the base class boolean conversion operator
494 using base_class::operator bool;
495
496 /// @brief Invoke the wrapped invocable as a const object, with the supplied
497 /// arguments
498 /// @param args The arguments for the call
499 /// @return The value returned from the call
500 auto operator()(Args... args) const noexcept(IsNoexcept) -> ReturnType {
501 ARENE_PRECONDITION(this->is_initialized());
502 return this->get_invoke()(*this, std::forward<Args>(args)...);
503 }
504};
505
506} // namespace base
507} // namespace arene
508
509// parasoft-end-suppress AUTOSAR-M2_10_1-a-2
510
511#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_INLINE_CONTAINER_FUNCTION_HPP_
auto operator=(inline_function const &) -> inline_function &=delete
Not copyable.
inline_function() noexcept=default
Default construct with no stored invocable.
auto operator=(inline_function &&other) noexcept -> inline_function &=default
Transfer ownership of an invocable from another object. Leaves the source without an invocable.
auto operator()(Args... args) noexcept(IsNoexcept) -> ReturnType
Invoke the wrapped invocable as a non-const object, with the supplied arguments.
Definition function.hpp:414
inline_function(inline_function &&other) noexcept=default
Transfer ownership of an invocable from another object. Leaves the source without an invocable.
auto operator()(Args... args) const noexcept(IsNoexcept) -> ReturnType
Invoke the wrapped invocable as a const object, with the supplied arguments.
Definition function.hpp:500
Definition array_exceptions_disabled.cpp:11
static constexpr std::size_t default_inline_function_size
The default size of the buffer used for inline_function .
Definition function.hpp:37
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10