StormByte 2.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 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
44
45#include <type_traits>
46
51namespace StormByte {
56 namespace Type {
63 namespace {
68 template<typename T, typename = void>
69 inline constexpr bool ReallyCopyConstructible =
70 requires(const T& src) { T{src}; };
71
76 template<typename T>
77 inline constexpr bool ReallyCopyConstructible<
78 T, std::enable_if_t<
79 Container<std::remove_cvref_t<T>> &&
80 !View<std::remove_cvref_t<T>>
81 >
82 > =
83 requires(const T& src) { T{src}; } &&
84 ReallyCopyConstructible<typename std::remove_cvref_t<T>::value_type>;
85
90 template<typename T, typename = void>
91 inline constexpr bool ReallyCopyAssignable =
92 requires(T& dest, const T& src) { dest = src; };
93
98 template<typename T>
99 inline constexpr bool ReallyCopyAssignable<
100 T, std::enable_if_t<
101 Container<std::remove_cvref_t<T>> &&
102 !View<std::remove_cvref_t<T>>
103 >
104 > =
105 requires(T& dest, const T& src) { dest = src; } &&
106 ReallyCopyAssignable<typename std::remove_cvref_t<T>::value_type>;
107 }
108
123 template<typename T>
124 concept TriviallyCopyable = std::is_trivially_copyable_v<T>;
125
135 template<typename T>
136 concept TriviallyDestructible = std::is_trivially_destructible_v<T>;
137
154 template<typename T>
155 concept DefaultConstructible = std::is_default_constructible_v<T>;
156
166 template<typename T>
167 concept TriviallyDefaultConstructible = std::is_trivially_default_constructible_v<T>;
168
187 template<typename T>
188 concept CopyConstructible = ReallyCopyConstructible<T>;
189
199 template<typename T>
200 concept TriviallyCopyConstructible = std::is_trivially_copy_constructible_v<T>;
201
211 template<typename T>
212 concept MoveConstructible = std::is_move_constructible_v<T>;
213
223 template<typename T>
224 concept TriviallyMoveConstructible = std::is_trivially_move_constructible_v<T>;
225
247 template<typename T>
248 concept CopyAssignable = ReallyCopyAssignable<T>;
249
259 template<typename T>
260 concept TriviallyCopyAssignable = std::is_trivially_copy_assignable_v<T>;
261
271 template<typename T>
272 concept MoveAssignable = std::is_move_assignable_v<T>;
273
283 template<typename T>
284 concept TriviallyMoveAssignable = std::is_trivially_move_assignable_v<T>;
285
302 template<typename T>
304
314 template<typename T>
316
326 template<typename T>
327 concept Swappable = std::is_swappable_v<T>;
328
331 }
332}
Type that can actually be copy-assigned.
Definition object_semantics.hxx:248
Type that can actually be copy-constructed.
Definition object_semantics.hxx:188
Both StormByte::Type::CopyConstructible and StormByte::Type::CopyAssignable.
Definition object_semantics.hxx:303
Type constructible from an empty initializer (T{} / T()).
Definition object_semantics.hxx:155
Both StormByte::Type::MoveConstructible and StormByte::Type::MoveAssignable.
Definition object_semantics.hxx:315
Type that can be move-assigned (operator=(T&&)).
Definition object_semantics.hxx:272
Type that can be move-constructed.
Definition object_semantics.hxx:212
Type that can be swapped with std::swap (std::is_swappable).
Definition object_semantics.hxx:327
StormByte::Type::CopyAssignable with a trivial copy-assignment operator.
Definition object_semantics.hxx:260
StormByte::Type::CopyConstructible with a trivial copy constructor.
Definition object_semantics.hxx:200
Type that may be copied with memcpy / as-if memcpy.
Definition object_semantics.hxx:124
StormByte::Type::DefaultConstructible with a trivial default constructor.
Definition object_semantics.hxx:167
Type with a trivial destructor.
Definition object_semantics.hxx:136
StormByte::Type::MoveAssignable with a trivial move-assignment operator.
Definition object_semantics.hxx:284
StormByte::Type::MoveConstructible with a trivial move constructor.
Definition object_semantics.hxx:224
Root namespace of the StormByte suite.
Octet count. Defined in byte_size.hxx. Forwarded so Type::Numeral can name it.