From: Joel Rosdahl Date: Fri, 25 Jul 2025 18:48:13 +0000 (+0200) Subject: bump: Upgrade to tl-expected 1.2.0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ee66d6f93e2aaba974eb1871b71411fee92990a;p=thirdparty%2Fccache.git bump: Upgrade to tl-expected 1.2.0 --- diff --git a/LICENSE.adoc b/LICENSE.adoc index 225d1879d..d75479a01 100644 --- a/LICENSE.adoc +++ b/LICENSE.adoc @@ -521,7 +521,7 @@ DEALINGS IN THE SOFTWARE. === src/third_party/tl-expected/tl/expected.hpp -This is https://github.com/TartanLlama/expected[TartanLlama expected] 1.1.0 with +This is https://github.com/TartanLlama/expected[TartanLlama expected] 1.2.0 with the following license: ---- diff --git a/src/third_party/tl-expected/tl/expected.hpp b/src/third_party/tl-expected/tl/expected.hpp index afee404d4..06e6dc4f6 100644 --- a/src/third_party/tl-expected/tl/expected.hpp +++ b/src/third_party/tl-expected/tl/expected.hpp @@ -17,7 +17,7 @@ #define TL_EXPECTED_HPP #define TL_EXPECTED_VERSION_MAJOR 1 -#define TL_EXPECTED_VERSION_MINOR 1 +#define TL_EXPECTED_VERSION_MINOR 2 #define TL_EXPECTED_VERSION_PATCH 0 #include @@ -53,7 +53,7 @@ #if !defined(TL_ASSERT) //can't have assert in constexpr in C++11 and GCC 4.9 has a compiler bug -#if (__cplusplus > 201103L) && !defined(TL_EXPECTED_GCC49) +#if (TL_CPLUSPLUS > 201103L) && !defined(TL_EXPECTED_GCC49) #include #define TL_ASSERT(x) assert(x) #else @@ -109,7 +109,13 @@ struct is_trivially_copy_constructible> : std::false_type {}; std::is_trivially_destructible #endif -#if __cplusplus > 201103L +#ifdef _MSVC_LANG +#define TL_CPLUSPLUS _MSVC_LANG +#else +#define TL_CPLUSPLUS __cplusplus +#endif + +#if TL_CPLUSPLUS > 201103L #define TL_EXPECTED_CXX14 #endif @@ -119,15 +125,21 @@ struct is_trivially_copy_constructible> : std::false_type {}; #define TL_EXPECTED_GCC49_CONSTEXPR constexpr #endif -#if (__cplusplus == 201103L || defined(TL_EXPECTED_MSVC2015) || \ +#if (TL_CPLUSPLUS == 201103L || defined(TL_EXPECTED_MSVC2015) || \ defined(TL_EXPECTED_GCC49)) #define TL_EXPECTED_11_CONSTEXPR #else #define TL_EXPECTED_11_CONSTEXPR constexpr #endif +#if TL_CPLUSPLUS >= 201703L +#define TL_EXPECTED_NODISCARD [[nodiscard]] +#else +#define TL_EXPECTED_NODISCARD +#endif + namespace tl { -template class expected; +template class TL_EXPECTED_NODISCARD expected; #ifndef TL_MONOSTATE_INPLACE_MUTEX #define TL_MONOSTATE_INPLACE_MUTEX @@ -522,6 +534,10 @@ template struct expected_storage_base { Args &&...args) : m_unexpect(il, std::forward(args)...), m_has_val(false) {} + expected_storage_base(const expected_storage_base &) = default; + expected_storage_base(expected_storage_base &&) = default; + expected_storage_base &operator=(const expected_storage_base &) = default; + expected_storage_base &operator=(expected_storage_base &&) = default; ~expected_storage_base() = default; union { T m_val; @@ -563,6 +579,10 @@ template struct expected_storage_base { Args &&...args) : m_unexpect(il, std::forward(args)...), m_has_val(false) {} + expected_storage_base(const expected_storage_base &) = default; + expected_storage_base(expected_storage_base &&) = default; + expected_storage_base &operator=(const expected_storage_base &) = default; + expected_storage_base &operator=(expected_storage_base &&) = default; ~expected_storage_base() { if (!m_has_val) { m_unexpect.~unexpected(); @@ -608,6 +628,10 @@ template struct expected_storage_base { Args &&...args) : m_unexpect(il, std::forward(args)...), m_has_val(false) {} + expected_storage_base(const expected_storage_base &) = default; + expected_storage_base(expected_storage_base &&) = default; + expected_storage_base &operator=(const expected_storage_base &) = default; + expected_storage_base &operator=(expected_storage_base &&) = default; ~expected_storage_base() { if (m_has_val) { m_val.~T(); @@ -648,6 +672,10 @@ template struct expected_storage_base { Args &&...args) : m_unexpect(il, std::forward(args)...), m_has_val(false) {} + expected_storage_base(const expected_storage_base &) = default; + expected_storage_base(expected_storage_base &&) = default; + expected_storage_base &operator=(const expected_storage_base &) = default; + expected_storage_base &operator=(expected_storage_base &&) = default; ~expected_storage_base() = default; struct dummy {}; union { @@ -678,6 +706,10 @@ template struct expected_storage_base { Args &&...args) : m_unexpect(il, std::forward(args)...), m_has_val(false) {} + expected_storage_base(const expected_storage_base &) = default; + expected_storage_base(expected_storage_base &&) = default; + expected_storage_base &operator=(const expected_storage_base &) = default; + expected_storage_base &operator=(expected_storage_base &&) = default; ~expected_storage_base() { if (!m_has_val) { m_unexpect.~unexpected(); @@ -936,14 +968,16 @@ struct expected_operations_base : expected_storage_base { // This specialization is for when T and E are trivially copy constructible template :: - value &&TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(E)::value> + value &&TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(E)::value, + bool = (is_copy_constructible_or_void::value && + std::is_copy_constructible::value)> struct expected_copy_base : expected_operations_base { using expected_operations_base::expected_operations_base; }; -// This specialization is for when T or E are not trivially copy constructible +// This specialization is for when T or E are non-trivially copy constructible template -struct expected_copy_base : expected_operations_base { +struct expected_copy_base : expected_operations_base { using expected_operations_base::expected_operations_base; expected_copy_base() = default; @@ -1004,13 +1038,17 @@ template >::value &&TL_EXPECTED_IS_TRIVIALLY_COPY_ASSIGNABLE(E)::value &&TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(E)::value - &&TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(E)::value> + &&TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(E)::value, + bool = (is_copy_constructible_or_void::value && + std::is_copy_constructible::value && + is_copy_assignable_or_void::value && + std::is_copy_assignable::value)> struct expected_copy_assign_base : expected_move_base { using expected_move_base::expected_move_base; }; template -struct expected_copy_assign_base : expected_move_base { +struct expected_copy_assign_base : expected_move_base { using expected_move_base::expected_move_base; expected_copy_assign_base() = default; @@ -1184,7 +1222,7 @@ struct default_constructor_tag { }; // expected_default_ctor_base will ensure that expected has a deleted default -// consturctor if T is not default constructible. +// constructor if T is not default constructible. // This specialization is for when T is default constructible template -class expected : private detail::expected_move_assign_base, +class TL_EXPECTED_NODISCARD expected : + private detail::expected_move_assign_base, private detail::expected_delete_ctor_base, private detail::expected_delete_assign_base, private detail::expected_default_ctor_base { @@ -2392,7 +2431,7 @@ constexpr bool operator!=(const expected &lhs, const expected &rhs) { return (lhs.has_value() != rhs.has_value()) ? true - : (!lhs.has_value() ? lhs.error() == rhs.error() : false); + : (!lhs.has_value() ? lhs.error() != rhs.error() : false); } template