StormByte 3.0.0
C++26 foundation of the StormByte suite
Loading...
Searching...
No Matches
object_semantics.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
45
46#include <type_traits>
47
52namespace StormByte {
57 namespace Type {
63
64 namespace {
69 template<typename T, typename = void>
70 inline constexpr bool ReallyCopyConstructible =
71 requires(const T& src) { T{src}; };
72
77 template<typename T>
78 inline constexpr bool ReallyCopyConstructible<
79 T, std::enable_if_t<
82 >
83 > =
84 requires(const T& src) { T{src}; } &&
85 ReallyCopyConstructible<typename std::remove_cvref_t<T>::value_type>;
86
91 template<typename T, typename = void>
92 inline constexpr bool ReallyCopyAssignable =
93 requires(T& dest, const T& src) { dest = src; };
94
99 template<typename T>
100 inline constexpr bool ReallyCopyAssignable<
101 T, std::enable_if_t<
104 >
105 > =
106 requires(T& dest, const T& src) { dest = src; } &&
107 ReallyCopyAssignable<typename std::remove_cvref_t<T>::value_type>;
108 }
109
114
124 template<typename T>
125 concept TriviallyCopyable = std::is_trivially_copyable_v<T>;
126
136 template<typename T>
137 concept TriviallyDestructible = std::is_trivially_destructible_v<T>;
138
140
145
155 template<typename T>
156 concept DefaultConstructible = std::is_default_constructible_v<T>;
157
167 template<typename T>
168 concept TriviallyDefaultConstructible = std::is_trivially_default_constructible_v<T>;
169
188 template<typename T>
189 concept CopyConstructible = ReallyCopyConstructible<T>;
190
200 template<typename T>
201 concept TriviallyCopyConstructible = std::is_trivially_copy_constructible_v<T>;
202
212 template<typename T>
213 concept MoveConstructible = std::is_move_constructible_v<T>;
214
224 template<typename T>
225 concept TriviallyMoveConstructible = std::is_trivially_move_constructible_v<T>;
226
228
233
248 template<typename T>
249 concept CopyAssignable = ReallyCopyAssignable<T>;
250
260 template<typename T>
261 concept TriviallyCopyAssignable = std::is_trivially_copy_assignable_v<T>;
262
272 template<typename T>
273 concept MoveAssignable = std::is_move_assignable_v<T>;
274
284 template<typename T>
285 concept TriviallyMoveAssignable = std::is_trivially_move_assignable_v<T>;
286
288
293
303 template<typename T>
305
315 template<typename T>
317
327 template<typename T>
328 concept Swappable = std::is_swappable_v<T>;
329
341 template<typename T>
342 concept Destructible = std::is_destructible_v<T>;
343
355 template<typename T, typename... Args>
356 concept ConstructibleFrom = std::constructible_from<T, Args...>;
357
371 template<typename T, typename U>
372 concept AssignableFrom = std::assignable_from<T, U>;
373
383 template<typename T>
385 requires(std::remove_cvref_t<T> const& a, std::remove_cvref_t<T> const& b) {
386 { a < b } -> std::convertible_to<bool>;
387 { a > b } -> std::convertible_to<bool>;
388 { a <= b } -> std::convertible_to<bool>;
389 { a >= b } -> std::convertible_to<bool>;
390 };
391
403 template<typename T>
405
415 template<typename T>
417
420 }
421}
T can be assigned from U (std::assignable_from).
Definition object_semantics.hxx:372
Type constructible from Args (std::constructible_from).
Definition object_semantics.hxx:356
Has begin(), end() and value_type, and is not a StormByte::Type::String.
Definition containers.hxx:172
Type that can actually be copy-assigned.
Definition object_semantics.hxx:249
Type that can actually be copy-constructed.
Definition object_semantics.hxx:189
Both StormByte::Type::CopyConstructible and StormByte::Type::CopyAssignable.
Definition object_semantics.hxx:304
Type constructible from an empty initializer (T{} / T()).
Definition object_semantics.hxx:156
Type that can be destroyed.
Definition object_semantics.hxx:342
Type whose == and != both yield something convertible to bool.
Definition comparison.hxx:81
Both StormByte::Type::MoveConstructible and StormByte::Type::MoveAssignable.
Definition object_semantics.hxx:316
Type that can be move-assigned (operator=(T&&)).
Definition object_semantics.hxx:273
Type that can be move-constructed.
Definition object_semantics.hxx:213
StormByte::Type::Semiregular and equality-comparable.
Definition object_semantics.hxx:416
Default-constructible, copyable and movable.
Definition object_semantics.hxx:404
Type that can be swapped with std::swap (std::is_swappable).
Definition object_semantics.hxx:328
Type with equality and a total order.
Definition object_semantics.hxx:384
StormByte::Type::CopyAssignable with a trivial copy-assignment operator.
Definition object_semantics.hxx:261
StormByte::Type::CopyConstructible with a trivial copy constructor.
Definition object_semantics.hxx:201
Type that may be copied with memcpy / as-if memcpy.
Definition object_semantics.hxx:125
StormByte::Type::DefaultConstructible with a trivial default constructor.
Definition object_semantics.hxx:168
Type with a trivial destructor.
Definition object_semantics.hxx:137
StormByte::Type::MoveAssignable with a trivial move-assignment operator.
Definition object_semantics.hxx:285
StormByte::Type::MoveConstructible with a trivial move constructor.
Definition object_semantics.hxx:225
Range view (std::ranges::view).
Definition ranges.hxx:142
Named concepts and small type utilities used across the suite.
Root namespace of the StormByte suite.