StormByte 2.0.0
C++26 foundation of the StormByte suite
 
Loading...
Searching...
No Matches
containers.hxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024-2026 David C. Manuelda (StormBytePP)
3 *
4 * This file is part of StormByte.
5 *
6 * StormByte original source is dual-licensed:
7 *
8 * 1. GNU Lesser General Public License v3.0 (or later)
9 * You may redistribute and/or modify this file under the terms of the
10 * GNU Lesser General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option)
12 * any later version.
13 *
14 * 2. Commercial license
15 * Alternatively, this file may be used under the terms of a commercial
16 * license agreement with the copyright holder
17 * (David C. Manuelda <StormByte@gmail.com>).
18 *
19 * Both licenses apply only to original StormByte source in this repository.
20 * They do not cover other StormByte modules or any third-party material
21 * shipped with this repository (including everything under thirdparty/),
22 * which remains under its own license.
23 *
24 * Neither license grants any patent rights. Any patent licenses required
25 * to use this software or third-party components must be obtained separately
26 * from the patent holders.
27 *
28 * StormByte is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU Lesser General Public License for more details.
32 *
33 * You should have received a copy of the GNU Lesser General Public License
34 * version 3 along with StormByte. If not, see
35 * <https://www.gnu.org/licenses/lgpl-3.0.html>.
36 *
37 * SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-StormByte-Commercial
38 */
39
40#pragma once
41
43
44#include <array>
45#include <concepts>
46#include <string>
47#include <tuple>
48#include <type_traits>
49#include <utility>
50
55namespace StormByte {
56 class Size;
57
62 namespace Safe {
63 class String;
64 class WString;
65 }
66
71 namespace Type {
100 template<typename T>
101 concept String =
108
116 namespace Detail {
121 template<typename T>
122 inline constexpr bool ArrayV = false;
123
133 template<typename U, std::size_t N>
134 inline constexpr bool ArrayV<std::array<U, N>> = true;
135 }
136
151 template<typename T>
152 concept Array = Detail::ArrayV<std::remove_cvref_t<T>>;
153
166 template<typename T>
167 concept Container =
168 requires(T t) {
169 t.begin();
170 t.end();
171 typename T::value_type;
173
186 template<typename C>
187 concept HasKeyType =
189 requires { typename std::remove_cvref_t<C>::key_type; };
190
202 template<typename C>
205 requires { typename std::remove_cvref_t<C>::mapped_type; };
206
220 template<typename C>
221 concept Sized =
223 requires(std::remove_cvref_t<C> const& c) {
224 c.size();
225 } &&
226 (
227 std::convertible_to<
228 decltype(std::declval<std::remove_cvref_t<C> const&>().size()),
229 std::size_t
230 > ||
231 SameAs<
232 decltype(std::declval<std::remove_cvref_t<C> const&>().size()),
233 Size
234 >
235 );
236
259 template<typename C>
260 concept HasPushBack =
262 (
263 requires(std::remove_cvref_t<C>& c,
264 typename std::remove_cvref_t<C>::value_type const& v) {
265 c.push_back(v);
266 } ||
267 requires(std::remove_cvref_t<C>& c,
268 typename std::remove_cvref_t<C>::value_type&& v) {
269 c.push_back(std::move(v));
270 }
271 );
272
286 template<typename C>
287 concept HasPushFront =
289 (
290 requires(std::remove_cvref_t<C>& c,
291 typename std::remove_cvref_t<C>::value_type const& v) {
292 c.push_front(v);
293 } ||
294 requires(std::remove_cvref_t<C>& c,
295 typename std::remove_cvref_t<C>::value_type&& v) {
296 c.push_front(std::move(v));
297 }
298 );
299
317 template<typename C>
318 concept HasInsert =
321 (
322 requires(std::remove_cvref_t<C>& c,
323 typename std::remove_cvref_t<C>::value_type const& v) {
324 c.insert(v);
325 } ||
326 requires(std::remove_cvref_t<C>& c,
327 typename std::remove_cvref_t<C>::value_type&& v) {
328 c.insert(std::move(v));
329 }
330 );
331
345 template<typename C, typename U>
346 concept HasSubscript = Container<C> && requires(C& c, U const& u) {
347 { c[u] };
348 };
349
352 }
353}
Count of abstract units (uint64_t storage).
Definition size.hxx:105
std::array<U, N> after stripping cv/ref.
Definition containers.hxx:152
Has begin(), end() and value_type, and is not a StormByte::Type::String.
Definition containers.hxx:167
Associative StormByte::Type::Container that accepts insert of a value_type.
Definition containers.hxx:318
StormByte::Type::Container that publishes a nested key_type.
Definition containers.hxx:187
StormByte::Type::Container that publishes a nested mapped_type.
Definition containers.hxx:203
StormByte::Type::Container that accepts push_back of a value_type.
Definition containers.hxx:260
StormByte::Type::Container that accepts push_front of a value_type.
Definition containers.hxx:287
StormByte::Type::Container that supports operator[] with key/index U.
Definition containers.hxx:346
Same type after stripping cv and references from both sides.
Definition relations.hxx:94
StormByte::Type::Container that publishes size().
Definition containers.hxx:221
Text string types that are not generic containers.
Definition containers.hxx:101
Private helpers.
constexpr bool ArrayV
Primary: T is not std::array.
Definition containers.hxx:122
Root namespace of the StormByte suite.
Octet count. Defined in byte_size.hxx. Forwarded so Type::Numeral can name it.