StormByte C++ Library 1.2.0
StormByte is a comprehensive, cross-platform C++ library aimed at easing system programming, configuration management, logging, and database handling tasks. This library provides a unified API that abstracts away the complexities and inconsistencies of different platforms (Windows, Linux).
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 is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License version 3
8 * or later, as published by the Free Software Foundation.
9 *
10 * StormByte is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with StormByte. If not, see
17 * <https://www.gnu.org/licenses/lgpl-3.0.html>.
18 */
19
20#pragma once
21
22#include <concepts>
23#include <string>
24#include <type_traits>
25#include <utility>
26
31namespace StormByte {
32 namespace Type {
52 template<typename T>
53 concept String =
54 std::same_as<T, std::string> ||
55 std::same_as<T, std::wstring> ||
56 std::same_as<T, std::u16string> ||
57 std::same_as<T, std::u32string>;
58
71 template<typename T>
72 concept Container =
73 requires(T t) {
74 t.begin();
75 t.end();
76 typename T::value_type;
78
91 template<typename C>
92 concept HasKeyType =
94 requires { typename std::remove_cvref_t<C>::key_type; };
95
107 template<typename C>
110 requires { typename std::remove_cvref_t<C>::mapped_type; };
111
127 template<typename C>
128 concept HasPushBack =
130 (
131 requires(std::remove_cvref_t<C>& c,
132 typename std::remove_cvref_t<C>::value_type const& v) {
133 c.push_back(v);
134 } ||
135 requires(std::remove_cvref_t<C>& c,
136 typename std::remove_cvref_t<C>::value_type&& v) {
137 c.push_back(std::move(v));
138 }
139 );
140
154 template<typename C>
155 concept HasPushFront =
157 (
158 requires(std::remove_cvref_t<C>& c,
159 typename std::remove_cvref_t<C>::value_type const& v) {
160 c.push_front(v);
161 } ||
162 requires(std::remove_cvref_t<C>& c,
163 typename std::remove_cvref_t<C>::value_type&& v) {
164 c.push_front(std::move(v));
165 }
166 );
167
185 template<typename C>
186 concept HasInsert =
189 (
190 requires(std::remove_cvref_t<C>& c,
191 typename std::remove_cvref_t<C>::value_type const& v) {
192 c.insert(v);
193 } ||
194 requires(std::remove_cvref_t<C>& c,
195 typename std::remove_cvref_t<C>::value_type&& v) {
196 c.insert(std::move(v));
197 }
198 );
199
210 template<typename C, typename U>
211 concept HasSubscript = Container<C> && requires(C& c, U const& u) {
212 { c[u] };
213 };
214
223 template<typename C>
224 concept Sized =
226 requires(std::remove_cvref_t<C> const& c) {
227 { c.size() } -> std::convertible_to<std::size_t>;
228 };
230 }
231}
Has begin(), end() and value_type, and is not a String.
Definition containers.hxx:72
Associative Container that accepts insert of a value_type.
Definition containers.hxx:186
Container that publishes a nested key_type.
Definition containers.hxx:92
Container that publishes a nested mapped_type.
Definition containers.hxx:108
Container that accepts push_back of a value_type.
Definition containers.hxx:128
Container that accepts push_front of a value_type.
Definition containers.hxx:155
Container that supports operator[] with key/index U.
Definition containers.hxx:211
Container that publishes size() convertible to std::size_t.
Definition containers.hxx:224
Text string types that are not generic containers.
Definition containers.hxx:53
Root namespace of the StormByte suite.