StormByte 3.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 is the base for StormByte Suite libraries.
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 {
66 class String;
70 class WString;
71 }
72
77 namespace Type {
83
88
105 template<typename T>
106 concept String =
113
115
120
121 namespace Detail {
126 template<typename T>
127 inline constexpr bool ArrayV = false;
128
138 template<typename U, std::size_t N>
139 inline constexpr bool ArrayV<std::array<U, N>> = true;
140 }
141
156 template<typename T>
158
171 template<typename T>
172 concept Container =
173 requires(T t) {
174 t.begin();
175 t.end();
176 typename T::value_type;
178
191 template<typename C>
192 concept HasKeyType =
194 requires { typename std::remove_cvref_t<C>::key_type; };
195
207 template<typename C>
210 requires { typename std::remove_cvref_t<C>::mapped_type; };
211
225 template<typename C>
226 concept Sized =
228 requires(std::remove_cvref_t<C> const& c) {
229 c.size();
230 } &&
231 (
232 std::convertible_to<
233 decltype(std::declval<std::remove_cvref_t<C> const&>().size()),
234 std::size_t
235 > ||
236 SameAs<
237 decltype(std::declval<std::remove_cvref_t<C> const&>().size()),
238 Size
239 >
240 );
241
243
248
264 template<typename C>
265 concept HasPushBack =
267 (
268 requires(std::remove_cvref_t<C>& c,
269 typename std::remove_cvref_t<C>::value_type const& v) {
270 c.push_back(v);
271 } ||
272 requires(std::remove_cvref_t<C>& c,
273 typename std::remove_cvref_t<C>::value_type&& v) {
274 c.push_back(std::move(v));
275 }
276 );
277
291 template<typename C>
292 concept HasPushFront =
294 (
295 requires(std::remove_cvref_t<C>& c,
296 typename std::remove_cvref_t<C>::value_type const& v) {
297 c.push_front(v);
298 } ||
299 requires(std::remove_cvref_t<C>& c,
300 typename std::remove_cvref_t<C>::value_type&& v) {
301 c.push_front(std::move(v));
302 }
303 );
304
322 template<typename C>
323 concept HasInsert =
326 (
327 requires(std::remove_cvref_t<C>& c,
328 typename std::remove_cvref_t<C>::value_type const& v) {
329 c.insert(v);
330 } ||
331 requires(std::remove_cvref_t<C>& c,
332 typename std::remove_cvref_t<C>::value_type&& v) {
333 c.insert(std::move(v));
334 }
335 );
336
350 template<typename C, typename U>
351 concept HasSubscript = Container<C> && requires(C& c, U const& u) {
352 { c[u] };
353 };
354
357 }
358}
Owned UTF-8 text.
Definition string.hxx:113
Wide counterpart of String.
Definition wstring.hxx:104
Count of abstract units (uint64_t storage).
Definition size.hxx:107
std::array<U, N> after stripping cv/ref.
Definition containers.hxx:157
Has begin(), end() and value_type, and is not a StormByte::Type::String.
Definition containers.hxx:172
Associative StormByte::Type::Container that accepts insert of a value_type.
Definition containers.hxx:323
StormByte::Type::Container that publishes a nested key_type.
Definition containers.hxx:192
StormByte::Type::Container that publishes a nested mapped_type.
Definition containers.hxx:208
StormByte::Type::Container that accepts push_back of a value_type.
Definition containers.hxx:265
StormByte::Type::Container that accepts push_front of a value_type.
Definition containers.hxx:292
StormByte::Type::Container that supports operator[] with key/index U.
Definition containers.hxx:351
Same type after stripping cv and references from both sides.
Definition relations.hxx:139
StormByte::Type::Container that publishes size().
Definition containers.hxx:226
Text string types that are not generic containers.
Definition containers.hxx:106
Private helpers.
Owned values that cross a DLL without the caller's CRT.
constexpr bool ArrayV
Primary: T is not std::array.
Definition containers.hxx:127
Named concepts and small type utilities used across the suite.
Root namespace of the StormByte suite.