Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
in_place.hpp
Go to the documentation of this file.
1// Copyright 2026, Toyota Motor Corporation
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_UTILITY_IN_PLACE_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_UTILITY_IN_PLACE_HPP_
7
8// IWYU pragma: private, include "arene/base/utility.hpp"
9// IWYU pragma: friend "(arene/base(?!/tests)|stdlib/include/stdlib_detail)/.*"
10
11///
12/// @file in_place.hpp
13/// @brief Provides backports of @c std::in_place_t, @c std::in_place_type_t, and @c std::in_place_index_t from C++17.
14///
15
17#include "arene/base/stdlib_choice/cstddef.hpp"
18
19namespace arene {
20namespace base {
21
22/// @brief backport of @c std::in_place_t from C++17
24 public:
25 /// @brief Explicit default constructor to prevent construction from @c {}
26 explicit in_place_t() = default;
27};
28
29// parasoft-begin-suppress AUTOSAR-M7_3_3-a "An unnamed namespace is used to create a per-TU reference to a global"
30// parasoft-begin-suppress CERT_CPP-DCL59-a "An unnamed namespace is used to create a per-TU reference to a global"
31// parasoft-begin-suppress AUTOSAR-M3_4_1-b "This is a per-TU reference to a global used in multiple TUs"
32// parasoft-begin-suppress CERT_CPP-DCL56-a-3 "False positive: variable is initialized"
33/// @brief backport of @c std::in_place from C++17, a tag variable for in-place construction
35// parasoft-end-suppress CERT_CPP-DCL56-a-3
36// parasoft-end-suppress AUTOSAR-M3_4_1-b
37// parasoft-end-suppress AUTOSAR-M7_3_3-a
38// parasoft-end-suppress CERT_CPP-DCL59-a
39
40/// @brief backport of @c std::in_place_type_t<T> from C++17
41template <typename T>
43 public:
44 /// @brief Explicit default constructor to prevent construction from @c {}
45 explicit in_place_type_t() = default;
46};
47
48/// @brief backport of @c std::in_place_type<T> from C++17
49template <typename T>
50extern constexpr in_place_type_t<T> in_place_type{};
51
52/// @brief backport of @c std::in_place_index_t<size_t> from C++17
53template <std::size_t I>
55 public:
56 /// @brief Explicit default constructor to prevent construction from @c {}
57 explicit in_place_index_t() = default;
58};
59
60/// @brief backport of @c std::in_place_index<T> from C++17
61template <std::size_t I>
62extern constexpr in_place_index_t<I> in_place_index{};
63
64} // namespace base
65} // namespace arene
66#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_UTILITY_IN_PLACE_HPP_
#define ARENE_CPP14_INLINE_VARIABLE(type, name)
Emulates C++17's inline variable declarations for function objects.
Definition cpp14_inline.hpp:69
backport of std::in_place_index_t<size_t> from C++17
Definition in_place.hpp:54
in_place_index_t()=default
Explicit default constructor to prevent construction from {}.
backport of std::in_place_t from C++17
Definition in_place.hpp:23
in_place_t()=default
Explicit default constructor to prevent construction from {}.
backport of std::in_place_type_t<T> from C++17
Definition in_place.hpp:42
in_place_type_t()=default
Explicit default constructor to prevent construction from {}.
Definition accumulate.hpp:37
constexpr in_place_type_t< T > in_place_type
backport of std::in_place_type<T> from C++17
constexpr in_place_index_t< I > in_place_index
backport of std::in_place_index<T> from C++17
Definition accumulate.hpp:36