| 1 |
From d99fc8961341d494597a62f5513573660a7f076f Mon Sep 17 00:00:00 2001 |
| 2 |
From: =?UTF-8?q?J=C3=B8ger=20Hanseg=C3=A5rd?= <[email protected]> |
| 3 |
Date: Tue, 18 Feb 2025 16:07:45 +0100 |
| 4 |
Subject: [PATCH 3/3] Adapt tl::expected to q23::expected |
| 5 |
|
| 6 |
--- |
| 7 |
include/tl/{expected.hpp => qexpected_p.h} | 33 ++++++++++++++++++---- |
| 8 |
1 file changed, 27 insertions(+), 6 deletions(-) |
| 9 |
rename include/tl/{expected.hpp => qexpected_p.h} (99%) |
| 10 |
|
| 11 |
diff --git a/include/tl/expected.hpp b/include/tl/qexpected_p.h |
| 12 |
similarity index 99% |
| 13 |
rename from include/tl/expected.hpp |
| 14 |
rename to include/tl/qexpected_p.h |
| 15 |
index 83920bd..a54aea1 100644 |
| 16 |
--- a/include/tl/expected.hpp |
| 17 |
+++ b/include/tl/qexpected_p.h |
| 18 |
@@ -16,15 +16,32 @@ |
| 19 |
#ifndef TL_EXPECTED_HPP |
| 20 |
#define TL_EXPECTED_HPP |
| 21 |
|
| 22 |
+// |
| 23 |
+// W A R N I N G |
| 24 |
+// ------------- |
| 25 |
+// |
| 26 |
+// This file is not part of the Qt API. It exists purely as an |
| 27 |
+// implementation detail. This header file may change from version to |
| 28 |
+// version without notice, or even be removed. |
| 29 |
+// |
| 30 |
+// We mean it. |
| 31 |
+// |
| 32 |
+ |
| 33 |
#define TL_EXPECTED_VERSION_MAJOR 1 |
| 34 |
#define TL_EXPECTED_VERSION_MINOR 1 |
| 35 |
#define TL_EXPECTED_VERSION_PATCH 0 |
| 36 |
|
| 37 |
+#include <QtCore/private/qglobal_p.h> |
| 38 |
+#include <QtCore/qassert.h> |
| 39 |
+#include <QtCore/qtconfigmacros.h> |
| 40 |
+ |
| 41 |
#include <exception> |
| 42 |
#include <functional> |
| 43 |
#include <type_traits> |
| 44 |
#include <utility> |
| 45 |
|
| 46 |
+#define TL_ASSERT Q_ASSERT |
| 47 |
+ |
| 48 |
#if defined(__EXCEPTIONS) || defined(_CPPUNWIND) |
| 49 |
#define TL_EXPECTED_EXCEPTIONS_ENABLED |
| 50 |
#endif |
| 51 |
@@ -81,7 +98,8 @@ |
| 52 |
#elif (defined(__GNUC__) && __GNUC__ < 8 && !defined(__clang__)) |
| 53 |
#ifndef TL_GCC_LESS_8_TRIVIALLY_COPY_CONSTRUCTIBLE_MUTEX |
| 54 |
#define TL_GCC_LESS_8_TRIVIALLY_COPY_CONSTRUCTIBLE_MUTEX |
| 55 |
-namespace tl { |
| 56 |
+QT_BEGIN_NAMESPACE |
| 57 |
+namespace q23 { |
| 58 |
namespace detail { |
| 59 |
template <class T> |
| 60 |
struct is_trivially_copy_constructible |
| 61 |
@@ -91,11 +109,12 @@ template <class T, class A> |
| 62 |
struct is_trivially_copy_constructible<std::vector<T, A>> : std::false_type {}; |
| 63 |
#endif |
| 64 |
} // namespace detail |
| 65 |
-} // namespace tl |
| 66 |
+} // namespace q23 |
| 67 |
+QT_END_NAMESPACE |
| 68 |
#endif |
| 69 |
|
| 70 |
#define TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) \ |
| 71 |
- tl::detail::is_trivially_copy_constructible<T> |
| 72 |
+ q23::detail::is_trivially_copy_constructible<T> |
| 73 |
#define TL_EXPECTED_IS_TRIVIALLY_COPY_ASSIGNABLE(T) \ |
| 74 |
std::is_trivially_copy_assignable<T> |
| 75 |
#define TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(T) \ |
| 76 |
@@ -132,7 +151,8 @@ struct is_trivially_copy_constructible<std::vector<T, A>> : std::false_type {}; |
| 77 |
#define TL_EXPECTED_11_CONSTEXPR constexpr |
| 78 |
#endif |
| 79 |
|
| 80 |
-namespace tl { |
| 81 |
+QT_BEGIN_NAMESPACE |
| 82 |
+namespace q23 { |
| 83 |
template <class T, class E> class expected; |
| 84 |
|
| 85 |
#ifndef TL_MONOSTATE_INPLACE_MUTEX |
| 86 |
@@ -396,7 +416,7 @@ struct is_nothrow_swappable |
| 87 |
#endif |
| 88 |
#endif |
| 89 |
|
| 90 |
-// Trait for checking if a type is a tl::expected |
| 91 |
+// Trait for checking if a type is a q23::expected |
| 92 |
template <class T> struct is_expected_impl : std::false_type {}; |
| 93 |
template <class T, class E> |
| 94 |
struct is_expected_impl<expected<T, E>> : std::true_type {}; |
| 95 |
@@ -2474,6 +2494,7 @@ void swap(expected<T, E> &lhs, |
| 96 |
expected<T, E> &rhs) noexcept(noexcept(lhs.swap(rhs))) { |
| 97 |
lhs.swap(rhs); |
| 98 |
} |
| 99 |
-} // namespace tl |
| 100 |
+} // namespace q23 |
| 101 |
+QT_END_NAMESPACE |
| 102 |
|
| 103 |
#endif |
| 104 |
-- |
| 105 |
2.44.0.windows.1 |
| 106 |
|