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
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 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
24
25#include <type_traits>
26
31namespace StormByte {
32 namespace Type {
39 namespace {
40 template<typename T, typename = void>
41 inline constexpr bool ReallyCopyConstructible =
42 requires(const T& src) { T{src}; };
43
44 template<typename T>
45 inline constexpr bool ReallyCopyConstructible<
46 T, std::enable_if_t<
47 Container<std::remove_cvref_t<T>> &&
48 !View<std::remove_cvref_t<T>>
49 >
50 > =
51 requires(const T& src) { T{src}; } &&
52 ReallyCopyConstructible<typename std::remove_cvref_t<T>::value_type>;
53
54 template<typename T, typename = void>
55 inline constexpr bool ReallyCopyAssignable =
56 requires(T& dest, const T& src) { dest = src; };
57
58 template<typename T>
59 inline constexpr bool ReallyCopyAssignable<
60 T, std::enable_if_t<
61 Container<std::remove_cvref_t<T>> &&
62 !View<std::remove_cvref_t<T>>
63 >
64 > =
65 requires(T& dest, const T& src) { dest = src; } &&
66 ReallyCopyAssignable<typename std::remove_cvref_t<T>::value_type>;
67 }
68
78 template<typename T>
79 concept TriviallyCopyable = std::is_trivially_copyable_v<T>;
80
90 template<typename T>
91 concept TriviallyDestructible = std::is_trivially_destructible_v<T>;
92
102 template<typename T>
103 concept DefaultConstructible = std::is_default_constructible_v<T>;
104
114 template<typename T>
115 concept TriviallyDefaultConstructible = std::is_trivially_default_constructible_v<T>;
116
135 template<typename T>
136 concept CopyConstructible = ReallyCopyConstructible<T>;
137
147 template<typename T>
148 concept TriviallyCopyConstructible = std::is_trivially_copy_constructible_v<T>;
149
164 template<typename T>
165 concept CopyAssignable = ReallyCopyAssignable<T>;
166
176 template<typename T>
177 concept TriviallyCopyAssignable = std::is_trivially_copy_assignable_v<T>;
178
188 template<typename T>
189 concept MoveConstructible = std::is_move_constructible_v<T>;
190
200 template<typename T>
201 concept TriviallyMoveConstructible = std::is_trivially_move_constructible_v<T>;
202
212 template<typename T>
213 concept MoveAssignable = std::is_move_assignable_v<T>;
214
224 template<typename T>
225 concept TriviallyMoveAssignable = std::is_trivially_move_assignable_v<T>;
226
236 template<typename T>
238
248 template<typename T>
250
260 template<typename T>
261 concept Swappable = std::is_swappable_v<T>;
263 }
264}
Type that can actually be copy-assigned.
Definition object_semantics.hxx:165
Type that can actually be copy-constructed.
Definition object_semantics.hxx:136
Both CopyConstructible and CopyAssignable.
Definition object_semantics.hxx:237
Type constructible from an empty initializer (T{} / T()).
Definition object_semantics.hxx:103
Both MoveConstructible and MoveAssignable.
Definition object_semantics.hxx:249
Type that can be move-assigned (operator=(T&&)).
Definition object_semantics.hxx:213
Type that can be move-constructed.
Definition object_semantics.hxx:189
Type that can be swapped with std::swap (std::is_swappable).
Definition object_semantics.hxx:261
CopyAssignable with a trivial copy-assignment operator.
Definition object_semantics.hxx:177
CopyConstructible with a trivial copy constructor.
Definition object_semantics.hxx:148
Type that may be copied with memcpy / as-if memcpy.
Definition object_semantics.hxx:79
DefaultConstructible with a trivial default constructor.
Definition object_semantics.hxx:115
Type with a trivial destructor.
Definition object_semantics.hxx:91
MoveAssignable with a trivial move-assignment operator.
Definition object_semantics.hxx:225
MoveConstructible with a trivial move constructor.
Definition object_semantics.hxx:201
Root namespace of the StormByte suite.