PyPartMC 2.1.2__cp315-cp315-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- PyPartMC/_PyPartMC.pyd +0 -0
- PyPartMC/__generate_si.py +37 -0
- PyPartMC/__init__.py +78 -0
- PyPartMC/cmake/PyPartMCConfig.cmake +65 -0
- PyPartMC/include/PyPartMC/aero_binned.hpp +117 -0
- PyPartMC/include/PyPartMC/aero_data.hpp +283 -0
- PyPartMC/include/PyPartMC/aero_dist.hpp +85 -0
- PyPartMC/include/PyPartMC/aero_mode.hpp +359 -0
- PyPartMC/include/PyPartMC/aero_particle.hpp +275 -0
- PyPartMC/include/PyPartMC/aero_state.hpp +664 -0
- PyPartMC/include/PyPartMC/bin_grid.hpp +143 -0
- PyPartMC/include/PyPartMC/camp_core.hpp +31 -0
- PyPartMC/include/PyPartMC/condense.hpp +35 -0
- PyPartMC/include/PyPartMC/env_state.hpp +161 -0
- PyPartMC/include/PyPartMC/gas_data.hpp +105 -0
- PyPartMC/include/PyPartMC/gas_state.hpp +129 -0
- PyPartMC/include/PyPartMC/getters.hpp +55 -0
- PyPartMC/include/PyPartMC/input_guard.hpp +155 -0
- PyPartMC/include/PyPartMC/json_resource.hpp +363 -0
- PyPartMC/include/PyPartMC/output.hpp +96 -0
- PyPartMC/include/PyPartMC/photolysis.hpp +29 -0
- PyPartMC/include/PyPartMC/pmc_resource.hpp +42 -0
- PyPartMC/include/PyPartMC/rand.hpp +12 -0
- PyPartMC/include/PyPartMC/run_exact.hpp +34 -0
- PyPartMC/include/PyPartMC/run_exact_opt.hpp +46 -0
- PyPartMC/include/PyPartMC/run_part.hpp +110 -0
- PyPartMC/include/PyPartMC/run_part_opt.hpp +72 -0
- PyPartMC/include/PyPartMC/run_sect.hpp +34 -0
- PyPartMC/include/PyPartMC/run_sect_opt.hpp +54 -0
- PyPartMC/include/PyPartMC/scenario.hpp +220 -0
- PyPartMC/include/PyPartMC/si.hpp +118 -0
- PyPartMC/include/PyPartMC/util.hpp +22 -0
- PyPartMC/include/PyPartMC.hpp +28 -0
- PyPartMC/include/aero_data_parameters.hpp +27 -0
- PyPartMC/include/bpstd/detail/string_view.inl +925 -0
- PyPartMC/include/bpstd/string_view.hpp +498 -0
- PyPartMC/include/gas_data_parameters.hpp +14 -0
- PyPartMC/include/nanobind_json/nanobind_json.h +226 -0
- PyPartMC/include/nlohmann/adl_serializer.hpp +55 -0
- PyPartMC/include/nlohmann/byte_container_with_subtype.hpp +103 -0
- PyPartMC/include/nlohmann/detail/abi_macros.hpp +100 -0
- PyPartMC/include/nlohmann/detail/conversions/from_json.hpp +497 -0
- PyPartMC/include/nlohmann/detail/conversions/to_chars.hpp +1118 -0
- PyPartMC/include/nlohmann/detail/conversions/to_json.hpp +446 -0
- PyPartMC/include/nlohmann/detail/exceptions.hpp +257 -0
- PyPartMC/include/nlohmann/detail/hash.hpp +129 -0
- PyPartMC/include/nlohmann/detail/input/binary_reader.hpp +3009 -0
- PyPartMC/include/nlohmann/detail/input/input_adapters.hpp +492 -0
- PyPartMC/include/nlohmann/detail/input/json_sax.hpp +727 -0
- PyPartMC/include/nlohmann/detail/input/lexer.hpp +1633 -0
- PyPartMC/include/nlohmann/detail/input/parser.hpp +519 -0
- PyPartMC/include/nlohmann/detail/input/position_t.hpp +37 -0
- PyPartMC/include/nlohmann/detail/iterators/internal_iterator.hpp +35 -0
- PyPartMC/include/nlohmann/detail/iterators/iter_impl.hpp +751 -0
- PyPartMC/include/nlohmann/detail/iterators/iteration_proxy.hpp +242 -0
- PyPartMC/include/nlohmann/detail/iterators/iterator_traits.hpp +61 -0
- PyPartMC/include/nlohmann/detail/iterators/json_reverse_iterator.hpp +130 -0
- PyPartMC/include/nlohmann/detail/iterators/primitive_iterator.hpp +132 -0
- PyPartMC/include/nlohmann/detail/json_custom_base_class.hpp +39 -0
- PyPartMC/include/nlohmann/detail/json_pointer.hpp +988 -0
- PyPartMC/include/nlohmann/detail/json_ref.hpp +78 -0
- PyPartMC/include/nlohmann/detail/macro_scope.hpp +482 -0
- PyPartMC/include/nlohmann/detail/macro_unscope.hpp +45 -0
- PyPartMC/include/nlohmann/detail/meta/call_std/begin.hpp +17 -0
- PyPartMC/include/nlohmann/detail/meta/call_std/end.hpp +17 -0
- PyPartMC/include/nlohmann/detail/meta/cpp_future.hpp +171 -0
- PyPartMC/include/nlohmann/detail/meta/detected.hpp +70 -0
- PyPartMC/include/nlohmann/detail/meta/identity_tag.hpp +21 -0
- PyPartMC/include/nlohmann/detail/meta/is_sax.hpp +159 -0
- PyPartMC/include/nlohmann/detail/meta/std_fs.hpp +29 -0
- PyPartMC/include/nlohmann/detail/meta/type_traits.hpp +795 -0
- PyPartMC/include/nlohmann/detail/meta/void_t.hpp +24 -0
- PyPartMC/include/nlohmann/detail/output/binary_writer.hpp +1838 -0
- PyPartMC/include/nlohmann/detail/output/output_adapters.hpp +147 -0
- PyPartMC/include/nlohmann/detail/output/serializer.hpp +988 -0
- PyPartMC/include/nlohmann/detail/string_concat.hpp +146 -0
- PyPartMC/include/nlohmann/detail/string_escape.hpp +72 -0
- PyPartMC/include/nlohmann/detail/value_t.hpp +118 -0
- PyPartMC/include/nlohmann/json.hpp +5258 -0
- PyPartMC/include/nlohmann/json_fwd.hpp +75 -0
- PyPartMC/include/nlohmann/ordered_map.hpp +359 -0
- PyPartMC/include/nlohmann/thirdparty/hedley/hedley.hpp +2045 -0
- PyPartMC/include/nlohmann/thirdparty/hedley/hedley_undef.hpp +158 -0
- PyPartMC/include/output_parameters.hpp +25 -0
- PyPartMC/include/tcb/span.hpp +617 -0
- PyPartMC/include/tl/optional.hpp +2062 -0
- PyPartMC/lib/libpartmclib.a +0 -0
- pypartmc-2.1.2.dist-info/METADATA +494 -0
- pypartmc-2.1.2.dist-info/RECORD +91 -0
- pypartmc-2.1.2.dist-info/WHEEL +5 -0
- pypartmc-2.1.2.dist-info/licenses/LICENSE +674 -0
|
@@ -0,0 +1,617 @@
|
|
|
1
|
+
|
|
2
|
+
/*
|
|
3
|
+
This is an implementation of C++20's std::span
|
|
4
|
+
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/n4820.pdf
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// Copyright Tristan Brindle 2018.
|
|
8
|
+
// Distributed under the Boost Software License, Version 1.0.
|
|
9
|
+
// (See accompanying file ../../LICENSE_1_0.txt or copy at
|
|
10
|
+
// https://www.boost.org/LICENSE_1_0.txt)
|
|
11
|
+
|
|
12
|
+
#ifndef TCB_SPAN_HPP_INCLUDED
|
|
13
|
+
#define TCB_SPAN_HPP_INCLUDED
|
|
14
|
+
|
|
15
|
+
#include <array>
|
|
16
|
+
#include <cstddef>
|
|
17
|
+
#include <cstdint>
|
|
18
|
+
#include <type_traits>
|
|
19
|
+
|
|
20
|
+
#ifndef TCB_SPAN_NO_EXCEPTIONS
|
|
21
|
+
// Attempt to discover whether we're being compiled with exception support
|
|
22
|
+
#if !(defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND))
|
|
23
|
+
#define TCB_SPAN_NO_EXCEPTIONS
|
|
24
|
+
#endif
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
#ifndef TCB_SPAN_NO_EXCEPTIONS
|
|
28
|
+
#include <cstdio>
|
|
29
|
+
#include <stdexcept>
|
|
30
|
+
#endif
|
|
31
|
+
|
|
32
|
+
// Various feature test macros
|
|
33
|
+
|
|
34
|
+
#ifndef TCB_SPAN_NAMESPACE_NAME
|
|
35
|
+
#define TCB_SPAN_NAMESPACE_NAME tcb
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
|
|
39
|
+
#define TCB_SPAN_HAVE_CPP17
|
|
40
|
+
#endif
|
|
41
|
+
|
|
42
|
+
#if __cplusplus >= 201402L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L)
|
|
43
|
+
#define TCB_SPAN_HAVE_CPP14
|
|
44
|
+
#endif
|
|
45
|
+
|
|
46
|
+
namespace TCB_SPAN_NAMESPACE_NAME {
|
|
47
|
+
|
|
48
|
+
// Establish default contract checking behavior
|
|
49
|
+
#if !defined(TCB_SPAN_THROW_ON_CONTRACT_VIOLATION) && \
|
|
50
|
+
!defined(TCB_SPAN_TERMINATE_ON_CONTRACT_VIOLATION) && \
|
|
51
|
+
!defined(TCB_SPAN_NO_CONTRACT_CHECKING)
|
|
52
|
+
#if defined(NDEBUG) || !defined(TCB_SPAN_HAVE_CPP14)
|
|
53
|
+
#define TCB_SPAN_NO_CONTRACT_CHECKING
|
|
54
|
+
#else
|
|
55
|
+
#define TCB_SPAN_TERMINATE_ON_CONTRACT_VIOLATION
|
|
56
|
+
#endif
|
|
57
|
+
#endif
|
|
58
|
+
|
|
59
|
+
#if defined(TCB_SPAN_THROW_ON_CONTRACT_VIOLATION)
|
|
60
|
+
struct contract_violation_error : std::logic_error {
|
|
61
|
+
explicit contract_violation_error(const char* msg) : std::logic_error(msg)
|
|
62
|
+
{}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
inline void contract_violation(const char* msg)
|
|
66
|
+
{
|
|
67
|
+
throw contract_violation_error(msg);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
#elif defined(TCB_SPAN_TERMINATE_ON_CONTRACT_VIOLATION)
|
|
71
|
+
[[noreturn]] inline void contract_violation(const char* /*unused*/)
|
|
72
|
+
{
|
|
73
|
+
std::terminate();
|
|
74
|
+
}
|
|
75
|
+
#endif
|
|
76
|
+
|
|
77
|
+
#if !defined(TCB_SPAN_NO_CONTRACT_CHECKING)
|
|
78
|
+
#define TCB_SPAN_STRINGIFY(cond) #cond
|
|
79
|
+
#define TCB_SPAN_EXPECT(cond) \
|
|
80
|
+
cond ? (void) 0 : contract_violation("Expected " TCB_SPAN_STRINGIFY(cond))
|
|
81
|
+
#else
|
|
82
|
+
#define TCB_SPAN_EXPECT(cond)
|
|
83
|
+
#endif
|
|
84
|
+
|
|
85
|
+
#if defined(TCB_SPAN_HAVE_CPP17) || defined(__cpp_inline_variables)
|
|
86
|
+
#define TCB_SPAN_INLINE_VAR inline
|
|
87
|
+
#else
|
|
88
|
+
#define TCB_SPAN_INLINE_VAR
|
|
89
|
+
#endif
|
|
90
|
+
|
|
91
|
+
#if defined(TCB_SPAN_HAVE_CPP14) || \
|
|
92
|
+
(defined(__cpp_constexpr) && __cpp_constexpr >= 201304)
|
|
93
|
+
#define TCB_SPAN_HAVE_CPP14_CONSTEXPR
|
|
94
|
+
#endif
|
|
95
|
+
|
|
96
|
+
#if defined(TCB_SPAN_HAVE_CPP14_CONSTEXPR)
|
|
97
|
+
#define TCB_SPAN_CONSTEXPR14 constexpr
|
|
98
|
+
#else
|
|
99
|
+
#define TCB_SPAN_CONSTEXPR14
|
|
100
|
+
#endif
|
|
101
|
+
|
|
102
|
+
#if defined(TCB_SPAN_HAVE_CPP14_CONSTEXPR) && \
|
|
103
|
+
(!defined(_MSC_VER) || _MSC_VER > 1900)
|
|
104
|
+
#define TCB_SPAN_CONSTEXPR_ASSIGN constexpr
|
|
105
|
+
#else
|
|
106
|
+
#define TCB_SPAN_CONSTEXPR_ASSIGN
|
|
107
|
+
#endif
|
|
108
|
+
|
|
109
|
+
#if defined(TCB_SPAN_NO_CONTRACT_CHECKING)
|
|
110
|
+
#define TCB_SPAN_CONSTEXPR11 constexpr
|
|
111
|
+
#else
|
|
112
|
+
#define TCB_SPAN_CONSTEXPR11 TCB_SPAN_CONSTEXPR14
|
|
113
|
+
#endif
|
|
114
|
+
|
|
115
|
+
#if defined(TCB_SPAN_HAVE_CPP17) || defined(__cpp_deduction_guides)
|
|
116
|
+
#define TCB_SPAN_HAVE_DEDUCTION_GUIDES
|
|
117
|
+
#endif
|
|
118
|
+
|
|
119
|
+
#if defined(TCB_SPAN_HAVE_CPP17) || defined(__cpp_lib_byte)
|
|
120
|
+
#define TCB_SPAN_HAVE_STD_BYTE
|
|
121
|
+
#endif
|
|
122
|
+
|
|
123
|
+
#if defined(TCB_SPAN_HAVE_CPP17) || defined(__cpp_lib_array_constexpr)
|
|
124
|
+
#define TCB_SPAN_HAVE_CONSTEXPR_STD_ARRAY_ETC
|
|
125
|
+
#endif
|
|
126
|
+
|
|
127
|
+
#if defined(TCB_SPAN_HAVE_CONSTEXPR_STD_ARRAY_ETC)
|
|
128
|
+
#define TCB_SPAN_ARRAY_CONSTEXPR constexpr
|
|
129
|
+
#else
|
|
130
|
+
#define TCB_SPAN_ARRAY_CONSTEXPR
|
|
131
|
+
#endif
|
|
132
|
+
|
|
133
|
+
#ifdef TCB_SPAN_HAVE_STD_BYTE
|
|
134
|
+
using byte = std::byte;
|
|
135
|
+
#else
|
|
136
|
+
using byte = unsigned char;
|
|
137
|
+
#endif
|
|
138
|
+
|
|
139
|
+
#if defined(TCB_SPAN_HAVE_CPP17)
|
|
140
|
+
#define TCB_SPAN_NODISCARD [[nodiscard]]
|
|
141
|
+
#else
|
|
142
|
+
#define TCB_SPAN_NODISCARD
|
|
143
|
+
#endif
|
|
144
|
+
|
|
145
|
+
TCB_SPAN_INLINE_VAR constexpr std::size_t dynamic_extent = SIZE_MAX;
|
|
146
|
+
|
|
147
|
+
template <typename ElementType, std::size_t Extent = dynamic_extent>
|
|
148
|
+
class span;
|
|
149
|
+
|
|
150
|
+
namespace detail {
|
|
151
|
+
|
|
152
|
+
template <typename E, std::size_t S>
|
|
153
|
+
struct span_storage {
|
|
154
|
+
constexpr span_storage() noexcept = default;
|
|
155
|
+
|
|
156
|
+
constexpr span_storage(E* p_ptr, std::size_t /*unused*/) noexcept
|
|
157
|
+
: ptr(p_ptr)
|
|
158
|
+
{}
|
|
159
|
+
|
|
160
|
+
E* ptr = nullptr;
|
|
161
|
+
static constexpr std::size_t size = S;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
template <typename E>
|
|
165
|
+
struct span_storage<E, dynamic_extent> {
|
|
166
|
+
constexpr span_storage() noexcept = default;
|
|
167
|
+
|
|
168
|
+
constexpr span_storage(E* p_ptr, std::size_t p_size) noexcept
|
|
169
|
+
: ptr(p_ptr), size(p_size)
|
|
170
|
+
{}
|
|
171
|
+
|
|
172
|
+
E* ptr = nullptr;
|
|
173
|
+
std::size_t size = 0;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// Reimplementation of C++17 std::size() and std::data()
|
|
177
|
+
#if defined(TCB_SPAN_HAVE_CPP17) || \
|
|
178
|
+
defined(__cpp_lib_nonmember_container_access)
|
|
179
|
+
using std::data;
|
|
180
|
+
using std::size;
|
|
181
|
+
#else
|
|
182
|
+
template <class C>
|
|
183
|
+
constexpr auto size(const C& c) -> decltype(c.size())
|
|
184
|
+
{
|
|
185
|
+
return c.size();
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
template <class T, std::size_t N>
|
|
189
|
+
constexpr std::size_t size(const T (&)[N]) noexcept
|
|
190
|
+
{
|
|
191
|
+
return N;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
template <class C>
|
|
195
|
+
constexpr auto data(C& c) -> decltype(c.data())
|
|
196
|
+
{
|
|
197
|
+
return c.data();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
template <class C>
|
|
201
|
+
constexpr auto data(const C& c) -> decltype(c.data())
|
|
202
|
+
{
|
|
203
|
+
return c.data();
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
template <class T, std::size_t N>
|
|
207
|
+
constexpr T* data(T (&array)[N]) noexcept
|
|
208
|
+
{
|
|
209
|
+
return array;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
template <class E>
|
|
213
|
+
constexpr const E* data(std::initializer_list<E> il) noexcept
|
|
214
|
+
{
|
|
215
|
+
return il.begin();
|
|
216
|
+
}
|
|
217
|
+
#endif // TCB_SPAN_HAVE_CPP17
|
|
218
|
+
|
|
219
|
+
#if defined(TCB_SPAN_HAVE_CPP17) || defined(__cpp_lib_void_t)
|
|
220
|
+
using std::void_t;
|
|
221
|
+
#else
|
|
222
|
+
template <typename...>
|
|
223
|
+
using void_t = void;
|
|
224
|
+
#endif
|
|
225
|
+
|
|
226
|
+
template <typename T>
|
|
227
|
+
using uncvref_t =
|
|
228
|
+
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
|
|
229
|
+
|
|
230
|
+
template <typename>
|
|
231
|
+
struct is_span : std::false_type {};
|
|
232
|
+
|
|
233
|
+
template <typename T, std::size_t S>
|
|
234
|
+
struct is_span<span<T, S>> : std::true_type {};
|
|
235
|
+
|
|
236
|
+
template <typename>
|
|
237
|
+
struct is_std_array : std::false_type {};
|
|
238
|
+
|
|
239
|
+
template <typename T, std::size_t N>
|
|
240
|
+
struct is_std_array<std::array<T, N>> : std::true_type {};
|
|
241
|
+
|
|
242
|
+
template <typename, typename = void>
|
|
243
|
+
struct has_size_and_data : std::false_type {};
|
|
244
|
+
|
|
245
|
+
template <typename T>
|
|
246
|
+
struct has_size_and_data<T, void_t<decltype(detail::size(std::declval<T>())),
|
|
247
|
+
decltype(detail::data(std::declval<T>()))>>
|
|
248
|
+
: std::true_type {};
|
|
249
|
+
|
|
250
|
+
template <typename C, typename U = uncvref_t<C>>
|
|
251
|
+
struct is_container {
|
|
252
|
+
static constexpr bool value =
|
|
253
|
+
!is_span<U>::value && !is_std_array<U>::value &&
|
|
254
|
+
!std::is_array<U>::value && has_size_and_data<C>::value;
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
template <typename T>
|
|
258
|
+
using remove_pointer_t = typename std::remove_pointer<T>::type;
|
|
259
|
+
|
|
260
|
+
template <typename, typename, typename = void>
|
|
261
|
+
struct is_container_element_type_compatible : std::false_type {};
|
|
262
|
+
|
|
263
|
+
template <typename T, typename E>
|
|
264
|
+
struct is_container_element_type_compatible<
|
|
265
|
+
T, E,
|
|
266
|
+
typename std::enable_if<
|
|
267
|
+
!std::is_same<
|
|
268
|
+
typename std::remove_cv<decltype(detail::data(std::declval<T>()))>::type,
|
|
269
|
+
void>::value &&
|
|
270
|
+
std::is_convertible<
|
|
271
|
+
remove_pointer_t<decltype(detail::data(std::declval<T>()))> (*)[],
|
|
272
|
+
E (*)[]>::value
|
|
273
|
+
>::type>
|
|
274
|
+
: std::true_type {};
|
|
275
|
+
|
|
276
|
+
template <typename, typename = size_t>
|
|
277
|
+
struct is_complete : std::false_type {};
|
|
278
|
+
|
|
279
|
+
template <typename T>
|
|
280
|
+
struct is_complete<T, decltype(sizeof(T))> : std::true_type {};
|
|
281
|
+
|
|
282
|
+
} // namespace detail
|
|
283
|
+
|
|
284
|
+
template <typename ElementType, std::size_t Extent>
|
|
285
|
+
class span {
|
|
286
|
+
static_assert(std::is_object<ElementType>::value,
|
|
287
|
+
"A span's ElementType must be an object type (not a "
|
|
288
|
+
"reference type or void)");
|
|
289
|
+
static_assert(detail::is_complete<ElementType>::value,
|
|
290
|
+
"A span's ElementType must be a complete type (not a forward "
|
|
291
|
+
"declaration)");
|
|
292
|
+
static_assert(!std::is_abstract<ElementType>::value,
|
|
293
|
+
"A span's ElementType cannot be an abstract class type");
|
|
294
|
+
|
|
295
|
+
using storage_type = detail::span_storage<ElementType, Extent>;
|
|
296
|
+
|
|
297
|
+
public:
|
|
298
|
+
// constants and types
|
|
299
|
+
using element_type = ElementType;
|
|
300
|
+
using value_type = typename std::remove_cv<ElementType>::type;
|
|
301
|
+
using size_type = std::size_t;
|
|
302
|
+
using difference_type = std::ptrdiff_t;
|
|
303
|
+
using pointer = element_type*;
|
|
304
|
+
using const_pointer = const element_type*;
|
|
305
|
+
using reference = element_type&;
|
|
306
|
+
using const_reference = const element_type&;
|
|
307
|
+
using iterator = pointer;
|
|
308
|
+
using reverse_iterator = std::reverse_iterator<iterator>;
|
|
309
|
+
|
|
310
|
+
static constexpr size_type extent = Extent;
|
|
311
|
+
|
|
312
|
+
// [span.cons], span constructors, copy, assignment, and destructor
|
|
313
|
+
template <
|
|
314
|
+
std::size_t E = Extent,
|
|
315
|
+
typename std::enable_if<(E == dynamic_extent || E <= 0), int>::type = 0>
|
|
316
|
+
constexpr span() noexcept
|
|
317
|
+
{}
|
|
318
|
+
|
|
319
|
+
TCB_SPAN_CONSTEXPR11 span(pointer ptr, size_type count)
|
|
320
|
+
: storage_(ptr, count)
|
|
321
|
+
{
|
|
322
|
+
TCB_SPAN_EXPECT(extent == dynamic_extent || count == extent);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
TCB_SPAN_CONSTEXPR11 span(pointer first_elem, pointer last_elem)
|
|
326
|
+
: storage_(first_elem, last_elem - first_elem)
|
|
327
|
+
{
|
|
328
|
+
TCB_SPAN_EXPECT(extent == dynamic_extent ||
|
|
329
|
+
last_elem - first_elem ==
|
|
330
|
+
static_cast<std::ptrdiff_t>(extent));
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
template <std::size_t N, std::size_t E = Extent,
|
|
334
|
+
typename std::enable_if<
|
|
335
|
+
(E == dynamic_extent || N == E) &&
|
|
336
|
+
detail::is_container_element_type_compatible<
|
|
337
|
+
element_type (&)[N], ElementType>::value,
|
|
338
|
+
int>::type = 0>
|
|
339
|
+
constexpr span(element_type (&arr)[N]) noexcept : storage_(arr, N)
|
|
340
|
+
{}
|
|
341
|
+
|
|
342
|
+
template <typename T, std::size_t N, std::size_t E = Extent,
|
|
343
|
+
typename std::enable_if<
|
|
344
|
+
(E == dynamic_extent || N == E) &&
|
|
345
|
+
detail::is_container_element_type_compatible<
|
|
346
|
+
std::array<T, N>&, ElementType>::value,
|
|
347
|
+
int>::type = 0>
|
|
348
|
+
TCB_SPAN_ARRAY_CONSTEXPR span(std::array<T, N>& arr) noexcept
|
|
349
|
+
: storage_(arr.data(), N)
|
|
350
|
+
{}
|
|
351
|
+
|
|
352
|
+
template <typename T, std::size_t N, std::size_t E = Extent,
|
|
353
|
+
typename std::enable_if<
|
|
354
|
+
(E == dynamic_extent || N == E) &&
|
|
355
|
+
detail::is_container_element_type_compatible<
|
|
356
|
+
const std::array<T, N>&, ElementType>::value,
|
|
357
|
+
int>::type = 0>
|
|
358
|
+
TCB_SPAN_ARRAY_CONSTEXPR span(const std::array<T, N>& arr) noexcept
|
|
359
|
+
: storage_(arr.data(), N)
|
|
360
|
+
{}
|
|
361
|
+
|
|
362
|
+
template <
|
|
363
|
+
typename Container, std::size_t E = Extent,
|
|
364
|
+
typename std::enable_if<
|
|
365
|
+
E == dynamic_extent && detail::is_container<Container>::value &&
|
|
366
|
+
detail::is_container_element_type_compatible<
|
|
367
|
+
Container&, ElementType>::value,
|
|
368
|
+
int>::type = 0>
|
|
369
|
+
constexpr span(Container& cont)
|
|
370
|
+
: storage_(detail::data(cont), detail::size(cont))
|
|
371
|
+
{}
|
|
372
|
+
|
|
373
|
+
template <
|
|
374
|
+
typename Container, std::size_t E = Extent,
|
|
375
|
+
typename std::enable_if<
|
|
376
|
+
E == dynamic_extent && detail::is_container<Container>::value &&
|
|
377
|
+
detail::is_container_element_type_compatible<
|
|
378
|
+
const Container&, ElementType>::value,
|
|
379
|
+
int>::type = 0>
|
|
380
|
+
constexpr span(const Container& cont)
|
|
381
|
+
: storage_(detail::data(cont), detail::size(cont))
|
|
382
|
+
{}
|
|
383
|
+
|
|
384
|
+
constexpr span(const span& other) noexcept = default;
|
|
385
|
+
|
|
386
|
+
template <typename OtherElementType, std::size_t OtherExtent,
|
|
387
|
+
typename std::enable_if<
|
|
388
|
+
(Extent == OtherExtent || Extent == dynamic_extent) &&
|
|
389
|
+
std::is_convertible<OtherElementType (*)[],
|
|
390
|
+
ElementType (*)[]>::value,
|
|
391
|
+
int>::type = 0>
|
|
392
|
+
constexpr span(const span<OtherElementType, OtherExtent>& other) noexcept
|
|
393
|
+
: storage_(other.data(), other.size())
|
|
394
|
+
{}
|
|
395
|
+
|
|
396
|
+
~span() noexcept = default;
|
|
397
|
+
|
|
398
|
+
TCB_SPAN_CONSTEXPR_ASSIGN span&
|
|
399
|
+
operator=(const span& other) noexcept = default;
|
|
400
|
+
|
|
401
|
+
// [span.sub], span subviews
|
|
402
|
+
template <std::size_t Count>
|
|
403
|
+
TCB_SPAN_CONSTEXPR11 span<element_type, Count> first() const
|
|
404
|
+
{
|
|
405
|
+
TCB_SPAN_EXPECT(Count <= size());
|
|
406
|
+
return {data(), Count};
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
template <std::size_t Count>
|
|
410
|
+
TCB_SPAN_CONSTEXPR11 span<element_type, Count> last() const
|
|
411
|
+
{
|
|
412
|
+
TCB_SPAN_EXPECT(Count <= size());
|
|
413
|
+
return {data() + (size() - Count), Count};
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
template <std::size_t Offset, std::size_t Count = dynamic_extent>
|
|
417
|
+
using subspan_return_t =
|
|
418
|
+
span<ElementType, Count != dynamic_extent
|
|
419
|
+
? Count
|
|
420
|
+
: (Extent != dynamic_extent ? Extent - Offset
|
|
421
|
+
: dynamic_extent)>;
|
|
422
|
+
|
|
423
|
+
template <std::size_t Offset, std::size_t Count = dynamic_extent>
|
|
424
|
+
TCB_SPAN_CONSTEXPR11 subspan_return_t<Offset, Count> subspan() const
|
|
425
|
+
{
|
|
426
|
+
TCB_SPAN_EXPECT(Offset <= size() &&
|
|
427
|
+
(Count == dynamic_extent || Offset + Count <= size()));
|
|
428
|
+
return {data() + Offset,
|
|
429
|
+
Count != dynamic_extent ? Count : size() - Offset};
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
TCB_SPAN_CONSTEXPR11 span<element_type, dynamic_extent>
|
|
433
|
+
first(size_type count) const
|
|
434
|
+
{
|
|
435
|
+
TCB_SPAN_EXPECT(count <= size());
|
|
436
|
+
return {data(), count};
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
TCB_SPAN_CONSTEXPR11 span<element_type, dynamic_extent>
|
|
440
|
+
last(size_type count) const
|
|
441
|
+
{
|
|
442
|
+
TCB_SPAN_EXPECT(count <= size());
|
|
443
|
+
return {data() + (size() - count), count};
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
TCB_SPAN_CONSTEXPR11 span<element_type, dynamic_extent>
|
|
447
|
+
subspan(size_type offset, size_type count = dynamic_extent) const
|
|
448
|
+
{
|
|
449
|
+
TCB_SPAN_EXPECT(offset <= size() &&
|
|
450
|
+
(count == dynamic_extent || offset + count <= size()));
|
|
451
|
+
return {data() + offset,
|
|
452
|
+
count == dynamic_extent ? size() - offset : count};
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// [span.obs], span observers
|
|
456
|
+
constexpr size_type size() const noexcept { return storage_.size; }
|
|
457
|
+
|
|
458
|
+
constexpr size_type size_bytes() const noexcept
|
|
459
|
+
{
|
|
460
|
+
return size() * sizeof(element_type);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
TCB_SPAN_NODISCARD constexpr bool empty() const noexcept
|
|
464
|
+
{
|
|
465
|
+
return size() == 0;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
// [span.elem], span element access
|
|
469
|
+
TCB_SPAN_CONSTEXPR11 reference operator[](size_type idx) const
|
|
470
|
+
{
|
|
471
|
+
TCB_SPAN_EXPECT(idx < size());
|
|
472
|
+
return *(data() + idx);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
TCB_SPAN_CONSTEXPR11 reference front() const
|
|
476
|
+
{
|
|
477
|
+
TCB_SPAN_EXPECT(!empty());
|
|
478
|
+
return *data();
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
TCB_SPAN_CONSTEXPR11 reference back() const
|
|
482
|
+
{
|
|
483
|
+
TCB_SPAN_EXPECT(!empty());
|
|
484
|
+
return *(data() + (size() - 1));
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
constexpr pointer data() const noexcept { return storage_.ptr; }
|
|
488
|
+
|
|
489
|
+
// [span.iterators], span iterator support
|
|
490
|
+
constexpr iterator begin() const noexcept { return data(); }
|
|
491
|
+
|
|
492
|
+
constexpr iterator end() const noexcept { return data() + size(); }
|
|
493
|
+
|
|
494
|
+
TCB_SPAN_ARRAY_CONSTEXPR reverse_iterator rbegin() const noexcept
|
|
495
|
+
{
|
|
496
|
+
return reverse_iterator(end());
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
TCB_SPAN_ARRAY_CONSTEXPR reverse_iterator rend() const noexcept
|
|
500
|
+
{
|
|
501
|
+
return reverse_iterator(begin());
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
private:
|
|
505
|
+
storage_type storage_{};
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
#ifdef TCB_SPAN_HAVE_DEDUCTION_GUIDES
|
|
509
|
+
|
|
510
|
+
/* Deduction Guides */
|
|
511
|
+
template <class T, size_t N>
|
|
512
|
+
span(T (&)[N])->span<T, N>;
|
|
513
|
+
|
|
514
|
+
template <class T, size_t N>
|
|
515
|
+
span(std::array<T, N>&)->span<T, N>;
|
|
516
|
+
|
|
517
|
+
template <class T, size_t N>
|
|
518
|
+
span(const std::array<T, N>&)->span<const T, N>;
|
|
519
|
+
|
|
520
|
+
template <class Container>
|
|
521
|
+
span(Container&)->span<typename std::remove_reference<
|
|
522
|
+
decltype(*detail::data(std::declval<Container&>()))>::type>;
|
|
523
|
+
|
|
524
|
+
template <class Container>
|
|
525
|
+
span(const Container&)->span<const typename Container::value_type>;
|
|
526
|
+
|
|
527
|
+
#endif // TCB_HAVE_DEDUCTION_GUIDES
|
|
528
|
+
|
|
529
|
+
template <typename ElementType, std::size_t Extent>
|
|
530
|
+
constexpr span<ElementType, Extent>
|
|
531
|
+
make_span(span<ElementType, Extent> s) noexcept
|
|
532
|
+
{
|
|
533
|
+
return s;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
template <typename T, std::size_t N>
|
|
537
|
+
constexpr span<T, N> make_span(T (&arr)[N]) noexcept
|
|
538
|
+
{
|
|
539
|
+
return {arr};
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
template <typename T, std::size_t N>
|
|
543
|
+
TCB_SPAN_ARRAY_CONSTEXPR span<T, N> make_span(std::array<T, N>& arr) noexcept
|
|
544
|
+
{
|
|
545
|
+
return {arr};
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
template <typename T, std::size_t N>
|
|
549
|
+
TCB_SPAN_ARRAY_CONSTEXPR span<const T, N>
|
|
550
|
+
make_span(const std::array<T, N>& arr) noexcept
|
|
551
|
+
{
|
|
552
|
+
return {arr};
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
template <typename Container>
|
|
556
|
+
constexpr span<typename std::remove_reference<
|
|
557
|
+
decltype(*detail::data(std::declval<Container&>()))>::type>
|
|
558
|
+
make_span(Container& cont)
|
|
559
|
+
{
|
|
560
|
+
return {cont};
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
template <typename Container>
|
|
564
|
+
constexpr span<const typename Container::value_type>
|
|
565
|
+
make_span(const Container& cont)
|
|
566
|
+
{
|
|
567
|
+
return {cont};
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
template <typename ElementType, std::size_t Extent>
|
|
571
|
+
span<const byte, ((Extent == dynamic_extent) ? dynamic_extent
|
|
572
|
+
: sizeof(ElementType) * Extent)>
|
|
573
|
+
as_bytes(span<ElementType, Extent> s) noexcept
|
|
574
|
+
{
|
|
575
|
+
return {reinterpret_cast<const byte*>(s.data()), s.size_bytes()};
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
template <
|
|
579
|
+
class ElementType, size_t Extent,
|
|
580
|
+
typename std::enable_if<!std::is_const<ElementType>::value, int>::type = 0>
|
|
581
|
+
span<byte, ((Extent == dynamic_extent) ? dynamic_extent
|
|
582
|
+
: sizeof(ElementType) * Extent)>
|
|
583
|
+
as_writable_bytes(span<ElementType, Extent> s) noexcept
|
|
584
|
+
{
|
|
585
|
+
return {reinterpret_cast<byte*>(s.data()), s.size_bytes()};
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
template <std::size_t N, typename E, std::size_t S>
|
|
589
|
+
constexpr auto get(span<E, S> s) -> decltype(s[N])
|
|
590
|
+
{
|
|
591
|
+
return s[N];
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
} // namespace TCB_SPAN_NAMESPACE_NAME
|
|
595
|
+
|
|
596
|
+
namespace std {
|
|
597
|
+
|
|
598
|
+
template <typename ElementType, size_t Extent>
|
|
599
|
+
class tuple_size<TCB_SPAN_NAMESPACE_NAME::span<ElementType, Extent>>
|
|
600
|
+
: public integral_constant<size_t, Extent> {};
|
|
601
|
+
|
|
602
|
+
template <typename ElementType>
|
|
603
|
+
class tuple_size<TCB_SPAN_NAMESPACE_NAME::span<
|
|
604
|
+
ElementType, TCB_SPAN_NAMESPACE_NAME::dynamic_extent>>; // not defined
|
|
605
|
+
|
|
606
|
+
template <size_t I, typename ElementType, size_t Extent>
|
|
607
|
+
class tuple_element<I, TCB_SPAN_NAMESPACE_NAME::span<ElementType, Extent>> {
|
|
608
|
+
public:
|
|
609
|
+
static_assert(Extent != TCB_SPAN_NAMESPACE_NAME::dynamic_extent &&
|
|
610
|
+
I < Extent,
|
|
611
|
+
"");
|
|
612
|
+
using type = ElementType;
|
|
613
|
+
};
|
|
614
|
+
|
|
615
|
+
} // end namespace std
|
|
616
|
+
|
|
617
|
+
#endif // TCB_SPAN_HPP_INCLUDED
|