From 0e38c7e126e4d313672a1be94139ca5cd9119345 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Thu, 27 Feb 2025 20:32:12 -0800 Subject: [PATCH] feat: Ada 3.1.3 --- test-app/runtime/src/main/cpp/ada/ada.cpp | 37 +- test-app/runtime/src/main/cpp/ada/ada.h | 1222 +++++++++++---------- 2 files changed, 642 insertions(+), 617 deletions(-) diff --git a/test-app/runtime/src/main/cpp/ada/ada.cpp b/test-app/runtime/src/main/cpp/ada/ada.cpp index 29e451c12..1d5df3767 100644 --- a/test-app/runtime/src/main/cpp/ada/ada.cpp +++ b/test-app/runtime/src/main/cpp/ada/ada.cpp @@ -1,4 +1,4 @@ -/* auto-generated on 2025-02-23 20:08:55 -0500. Do not edit! */ +/* auto-generated on 2025-02-26 20:29:12 -0500. Do not edit! */ /* begin file src/ada.cpp */ #include "ada.h" /* begin file src/checkers.cpp */ @@ -64,24 +64,23 @@ ada_really_inline constexpr bool is_ipv4(std::string_view view) noexcept { // encoding. static constexpr std::array path_signature_table = []() consteval { - std::array result{}; - for (size_t i = 0; i < 256; i++) { - if (i <= 0x20 || i == 0x22 || i == 0x23 || i == 0x3c || i == 0x3e || - i == 0x3f || i == 0x60 || i == 0x7b || i == 0x7d || i > 0x7e) { - result[i] = 1; - } else if (i == 0x25) { - result[i] = 8; - } else if (i == 0x2e) { - result[i] = 4; - } else if (i == 0x5c) { - result[i] = 2; - } else { - result[i] = 0; - } - } - return result; -} -(); + std::array result{}; + for (size_t i = 0; i < 256; i++) { + if (i <= 0x20 || i == 0x22 || i == 0x23 || i == 0x3c || i == 0x3e || + i == 0x3f || i == 0x60 || i == 0x7b || i == 0x7d || i > 0x7e) { + result[i] = 1; + } else if (i == 0x25) { + result[i] = 8; + } else if (i == 0x2e) { + result[i] = 4; + } else if (i == 0x5c) { + result[i] = 2; + } else { + result[i] = 0; + } + } + return result; + }(); ada_really_inline constexpr uint8_t path_signature( std::string_view input) noexcept { diff --git a/test-app/runtime/src/main/cpp/ada/ada.h b/test-app/runtime/src/main/cpp/ada/ada.h index 999b33f87..1252d1807 100644 --- a/test-app/runtime/src/main/cpp/ada/ada.h +++ b/test-app/runtime/src/main/cpp/ada/ada.h @@ -1,4 +1,4 @@ -/* auto-generated on 2025-02-23 20:08:55 -0500. Do not edit! */ +/* auto-generated on 2025-02-26 20:29:12 -0500. Do not edit! */ /* begin file include/ada.h */ /** * @file ada.h @@ -290,7 +290,8 @@ bool valid_name_code_point(char32_t input, bool first); ADA_DISABLE_GCC_WARNING("-Wreturn-type") \ ADA_DISABLE_GCC_WARNING("-Wshadow") \ ADA_DISABLE_GCC_WARNING("-Wunused-parameter") \ - ADA_DISABLE_GCC_WARNING("-Wunused-variable") + ADA_DISABLE_GCC_WARNING("-Wunused-variable") \ + ADA_DISABLE_GCC_WARNING("-Wsign-compare") #define ADA_PRAGMA(P) _Pragma(#P) #define ADA_DISABLE_GCC_WARNING(WARNING) \ ADA_PRAGMA(GCC diagnostic ignored WARNING) @@ -479,6 +480,7 @@ ada_really_inline constexpr bool bit_at(const uint8_t a[], uint8_t i); #ifndef ADA_CHARACTER_SETS_INL_H #define ADA_CHARACTER_SETS_INL_H + /** * These functions are not part of our public API and may * change at any time. @@ -1149,6 +1151,7 @@ ada_warn_unused std::string to_string(encoding_type type); #ifndef ADA_SCHEME_H #define ADA_SCHEME_H + #include /** @@ -1351,9 +1354,9 @@ struct url_base { #endif /* end file include/ada/url_base.h */ -#include #include #include +#include #if ADA_DEVELOPMENT_CHECKS #include @@ -1743,25 +1746,25 @@ class unexpected { static_assert(!std::is_same::value, "E must not be void"); unexpected() = delete; - constexpr explicit unexpected(const E& e) : m_val(e) {} + constexpr explicit unexpected(const E &e) : m_val(e) {} - constexpr explicit unexpected(E&& e) : m_val(std::move(e)) {} + constexpr explicit unexpected(E &&e) : m_val(std::move(e)) {} template ::value>::type* = nullptr> - constexpr explicit unexpected(Args&&... args) + E, Args &&...>::value>::type * = nullptr> + constexpr explicit unexpected(Args &&...args) : m_val(std::forward(args)...) {} template < class U, class... Args, typename std::enable_if&, Args&&...>::value>::type* = nullptr> - constexpr explicit unexpected(std::initializer_list l, Args&&... args) + E, std::initializer_list &, Args &&...>::value>::type * = nullptr> + constexpr explicit unexpected(std::initializer_list l, Args &&...args) : m_val(l, std::forward(args)...) {} - constexpr const E& value() const& { return m_val; } - TL_EXPECTED_11_CONSTEXPR E& value() & { return m_val; } - TL_EXPECTED_11_CONSTEXPR E&& value() && { return std::move(m_val); } - constexpr const E&& value() const&& { return std::move(m_val); } + constexpr const E &value() const & { return m_val; } + TL_EXPECTED_11_CONSTEXPR E &value() & { return m_val; } + TL_EXPECTED_11_CONSTEXPR E &&value() && { return std::move(m_val); } + constexpr const E &&value() const && { return std::move(m_val); } private: E m_val; @@ -1773,32 +1776,32 @@ unexpected(E) -> unexpected; #endif template -constexpr bool operator==(const unexpected& lhs, const unexpected& rhs) { +constexpr bool operator==(const unexpected &lhs, const unexpected &rhs) { return lhs.value() == rhs.value(); } template -constexpr bool operator!=(const unexpected& lhs, const unexpected& rhs) { +constexpr bool operator!=(const unexpected &lhs, const unexpected &rhs) { return lhs.value() != rhs.value(); } template -constexpr bool operator<(const unexpected& lhs, const unexpected& rhs) { +constexpr bool operator<(const unexpected &lhs, const unexpected &rhs) { return lhs.value() < rhs.value(); } template -constexpr bool operator<=(const unexpected& lhs, const unexpected& rhs) { +constexpr bool operator<=(const unexpected &lhs, const unexpected &rhs) { return lhs.value() <= rhs.value(); } template -constexpr bool operator>(const unexpected& lhs, const unexpected& rhs) { +constexpr bool operator>(const unexpected &lhs, const unexpected &rhs) { return lhs.value() > rhs.value(); } template -constexpr bool operator>=(const unexpected& lhs, const unexpected& rhs) { +constexpr bool operator>=(const unexpected &lhs, const unexpected &rhs) { return lhs.value() >= rhs.value(); } template -unexpected::type> make_unexpected(E&& e) { +unexpected::type> make_unexpected(E &&e) { return unexpected::type>(std::forward(e)); } @@ -1809,7 +1812,7 @@ static constexpr unexpect_t unexpect{}; namespace detail { template -[[noreturn]] TL_EXPECTED_11_CONSTEXPR void throw_exception(E&& e) { +[[noreturn]] TL_EXPECTED_11_CONSTEXPR void throw_exception(E &&e) { #ifdef TL_EXPECTED_EXCEPTIONS_ENABLED throw std::forward(e); #else @@ -1859,7 +1862,7 @@ template struct is_pointer_to_non_const_member_func : std::true_type {}; template -struct is_pointer_to_non_const_member_func +struct is_pointer_to_non_const_member_func : std::true_type {}; template struct is_pointer_to_non_const_member_func @@ -1868,16 +1871,16 @@ template struct is_pointer_to_non_const_member_func : std::true_type {}; template -struct is_pointer_to_non_const_member_func +struct is_pointer_to_non_const_member_func : std::true_type {}; template -struct is_pointer_to_non_const_member_func +struct is_pointer_to_non_const_member_func : std::true_type {}; template struct is_const_or_const_ref : std::false_type {}; template -struct is_const_or_const_ref : std::true_type {}; +struct is_const_or_const_ref : std::true_type {}; template struct is_const_or_const_ref : std::true_type {}; #endif @@ -1891,7 +1894,7 @@ template < is_const_or_const_ref::value)>, #endif typename = enable_if_t>::value>, int = 0> -constexpr auto invoke(Fn&& f, Args&&... args) noexcept( +constexpr auto invoke(Fn &&f, Args &&...args) noexcept( noexcept(std::mem_fn(f)(std::forward(args)...))) -> decltype(std::mem_fn(f)(std::forward(args)...)) { return std::mem_fn(f)(std::forward(args)...); @@ -1899,7 +1902,7 @@ constexpr auto invoke(Fn&& f, Args&&... args) noexcept( template >::value>> -constexpr auto invoke(Fn&& f, Args&&... args) noexcept( +constexpr auto invoke(Fn &&f, Args &&...args) noexcept( noexcept(std::forward(f)(std::forward(args)...))) -> decltype(std::forward(f)(std::forward(args)...)) { return std::forward(f)(std::forward(args)...); @@ -1939,7 +1942,7 @@ namespace swap_adl_tests { struct tag {}; template -tag swap(T&, T&); +tag swap(T &, T &); template tag swap(T (&a)[N], T (&b)[N]); @@ -1948,14 +1951,14 @@ tag swap(T (&a)[N], T (&b)[N]); template std::false_type can_swap(...) noexcept(false); template (), std::declval()))> -std::true_type can_swap(int) noexcept(noexcept(swap(std::declval(), - std::declval()))); + class = decltype(swap(std::declval(), std::declval()))> +std::true_type can_swap(int) noexcept(noexcept(swap(std::declval(), + std::declval()))); template std::false_type uses_std(...); template -std::is_same(), std::declval())), tag> +std::is_same(), std::declval())), tag> uses_std(int); template @@ -1986,8 +1989,8 @@ struct is_swappable : std::integral_constant< bool, decltype(detail::swap_adl_tests::can_swap(0))::value && - (!decltype( - detail::swap_adl_tests::uses_std(0))::value || + (!decltype(detail::swap_adl_tests::uses_std( + 0))::value || is_swappable::value)> {}; template @@ -1995,12 +1998,10 @@ struct is_nothrow_swappable : std::integral_constant< bool, is_swappable::value && - ((decltype(detail::swap_adl_tests::uses_std(0))::value&& - detail::swap_adl_tests::is_std_swap_noexcept::value) || - (!decltype(detail::swap_adl_tests::uses_std(0))::value&& - detail::swap_adl_tests::is_adl_swap_noexcept::value))> { -}; + ((decltype(detail::swap_adl_tests::uses_std(0))::value && + detail::swap_adl_tests::is_std_swap_noexcept::value) || + (!decltype(detail::swap_adl_tests::uses_std(0))::value && + detail::swap_adl_tests::is_adl_swap_noexcept::value))> {}; #endif #endif @@ -2014,7 +2015,7 @@ using is_expected = is_expected_impl>; template using expected_enable_forward_value = detail::enable_if_t< - std::is_constructible::value && + std::is_constructible::value && !std::is_same, in_place_t>::value && !std::is_same, detail::decay_t>::value && !std::is_same, detail::decay_t>::value>; @@ -2023,14 +2024,14 @@ template using expected_enable_from_other = detail::enable_if_t< std::is_constructible::value && std::is_constructible::value && - !std::is_constructible&>::value && - !std::is_constructible&&>::value && - !std::is_constructible&>::value && - !std::is_constructible&&>::value && - !std::is_convertible&, T>::value && - !std::is_convertible&&, T>::value && - !std::is_convertible&, T>::value && - !std::is_convertible&&, T>::value>; + !std::is_constructible &>::value && + !std::is_constructible &&>::value && + !std::is_constructible &>::value && + !std::is_constructible &&>::value && + !std::is_convertible &, T>::value && + !std::is_convertible &&, T>::value && + !std::is_convertible &, T>::value && + !std::is_convertible &&, T>::value>; template using is_void_or = conditional_t::value, std::true_type, U>; @@ -2068,29 +2069,29 @@ struct expected_storage_base { constexpr expected_storage_base(no_init_t) : m_no_init(), m_has_val(false) {} template ::value>* = + detail::enable_if_t::value> * = nullptr> - constexpr expected_storage_base(in_place_t, Args&&... args) + constexpr expected_storage_base(in_place_t, Args &&...args) : m_val(std::forward(args)...), m_has_val(true) {} template &, Args&&...>::value>* = nullptr> + T, std::initializer_list &, Args &&...>::value> * = nullptr> constexpr expected_storage_base(in_place_t, std::initializer_list il, - Args&&... args) + Args &&...args) : m_val(il, std::forward(args)...), m_has_val(true) {} template ::value>* = + detail::enable_if_t::value> * = nullptr> - constexpr explicit expected_storage_base(unexpect_t, Args&&... args) + constexpr explicit expected_storage_base(unexpect_t, Args &&...args) : m_unexpect(std::forward(args)...), m_has_val(false) {} template &, Args&&...>::value>* = nullptr> + E, std::initializer_list &, Args &&...>::value> * = nullptr> constexpr explicit expected_storage_base(unexpect_t, std::initializer_list il, - Args&&... args) + Args &&...args) : m_unexpect(il, std::forward(args)...), m_has_val(false) {} ~expected_storage_base() { @@ -2116,29 +2117,29 @@ struct expected_storage_base { constexpr expected_storage_base(no_init_t) : m_no_init(), m_has_val(false) {} template ::value>* = + detail::enable_if_t::value> * = nullptr> - constexpr expected_storage_base(in_place_t, Args&&... args) + constexpr expected_storage_base(in_place_t, Args &&...args) : m_val(std::forward(args)...), m_has_val(true) {} template &, Args&&...>::value>* = nullptr> + T, std::initializer_list &, Args &&...>::value> * = nullptr> constexpr expected_storage_base(in_place_t, std::initializer_list il, - Args&&... args) + Args &&...args) : m_val(il, std::forward(args)...), m_has_val(true) {} template ::value>* = + detail::enable_if_t::value> * = nullptr> - constexpr explicit expected_storage_base(unexpect_t, Args&&... args) + constexpr explicit expected_storage_base(unexpect_t, Args &&...args) : m_unexpect(std::forward(args)...), m_has_val(false) {} template &, Args&&...>::value>* = nullptr> + E, std::initializer_list &, Args &&...>::value> * = nullptr> constexpr explicit expected_storage_base(unexpect_t, std::initializer_list il, - Args&&... args) + Args &&...args) : m_unexpect(il, std::forward(args)...), m_has_val(false) {} ~expected_storage_base() = default; @@ -2158,29 +2159,29 @@ struct expected_storage_base { : m_no_init(), m_has_val(false) {} template ::value>* = + detail::enable_if_t::value> * = nullptr> - constexpr expected_storage_base(in_place_t, Args&&... args) + constexpr expected_storage_base(in_place_t, Args &&...args) : m_val(std::forward(args)...), m_has_val(true) {} template &, Args&&...>::value>* = nullptr> + T, std::initializer_list &, Args &&...>::value> * = nullptr> constexpr expected_storage_base(in_place_t, std::initializer_list il, - Args&&... args) + Args &&...args) : m_val(il, std::forward(args)...), m_has_val(true) {} template ::value>* = + detail::enable_if_t::value> * = nullptr> - constexpr explicit expected_storage_base(unexpect_t, Args&&... args) + constexpr explicit expected_storage_base(unexpect_t, Args &&...args) : m_unexpect(std::forward(args)...), m_has_val(false) {} template &, Args&&...>::value>* = nullptr> + E, std::initializer_list &, Args &&...>::value> * = nullptr> constexpr explicit expected_storage_base(unexpect_t, std::initializer_list il, - Args&&... args) + Args &&...args) : m_unexpect(il, std::forward(args)...), m_has_val(false) {} ~expected_storage_base() { @@ -2204,29 +2205,29 @@ struct expected_storage_base { constexpr expected_storage_base(no_init_t) : m_no_init(), m_has_val(false) {} template ::value>* = + detail::enable_if_t::value> * = nullptr> - constexpr expected_storage_base(in_place_t, Args&&... args) + constexpr expected_storage_base(in_place_t, Args &&...args) : m_val(std::forward(args)...), m_has_val(true) {} template &, Args&&...>::value>* = nullptr> + T, std::initializer_list &, Args &&...>::value> * = nullptr> constexpr expected_storage_base(in_place_t, std::initializer_list il, - Args&&... args) + Args &&...args) : m_val(il, std::forward(args)...), m_has_val(true) {} template ::value>* = + detail::enable_if_t::value> * = nullptr> - constexpr explicit expected_storage_base(unexpect_t, Args&&... args) + constexpr explicit expected_storage_base(unexpect_t, Args &&...args) : m_unexpect(std::forward(args)...), m_has_val(false) {} template &, Args&&...>::value>* = nullptr> + E, std::initializer_list &, Args &&...>::value> * = nullptr> constexpr explicit expected_storage_base(unexpect_t, std::initializer_list il, - Args&&... args) + Args &&...args) : m_unexpect(il, std::forward(args)...), m_has_val(false) {} ~expected_storage_base() { @@ -2257,17 +2258,17 @@ struct expected_storage_base { constexpr expected_storage_base(in_place_t) : m_has_val(true) {} template ::value>* = + detail::enable_if_t::value> * = nullptr> - constexpr explicit expected_storage_base(unexpect_t, Args&&... args) + constexpr explicit expected_storage_base(unexpect_t, Args &&...args) : m_unexpect(std::forward(args)...), m_has_val(false) {} template &, Args&&...>::value>* = nullptr> + E, std::initializer_list &, Args &&...>::value> * = nullptr> constexpr explicit expected_storage_base(unexpect_t, std::initializer_list il, - Args&&... args) + Args &&...args) : m_unexpect(il, std::forward(args)...), m_has_val(false) {} ~expected_storage_base() = default; @@ -2288,17 +2289,17 @@ struct expected_storage_base { constexpr expected_storage_base(in_place_t) : m_dummy(), m_has_val(true) {} template ::value>* = + detail::enable_if_t::value> * = nullptr> - constexpr explicit expected_storage_base(unexpect_t, Args&&... args) + constexpr explicit expected_storage_base(unexpect_t, Args &&...args) : m_unexpect(std::forward(args)...), m_has_val(false) {} template &, Args&&...>::value>* = nullptr> + E, std::initializer_list &, Args &&...>::value> * = nullptr> constexpr explicit expected_storage_base(unexpect_t, std::initializer_list il, - Args&&... args) + Args &&...args) : m_unexpect(il, std::forward(args)...), m_has_val(false) {} ~expected_storage_base() { @@ -2321,19 +2322,19 @@ struct expected_operations_base : expected_storage_base { using expected_storage_base::expected_storage_base; template - void construct(Args&&... args) noexcept { + void construct(Args &&...args) noexcept { new (std::addressof(this->m_val)) T(std::forward(args)...); this->m_has_val = true; } template - void construct_with(Rhs&& rhs) noexcept { + void construct_with(Rhs &&rhs) noexcept { new (std::addressof(this->m_val)) T(std::forward(rhs).get()); this->m_has_val = true; } template - void construct_error(Args&&... args) noexcept { + void construct_error(Args &&...args) noexcept { new (std::addressof(this->m_unexpect)) unexpected(std::forward(args)...); this->m_has_val = false; @@ -2348,9 +2349,9 @@ struct expected_operations_base : expected_storage_base { // This overload handles the case where we can just copy-construct `T` // directly into place without throwing. template ::value>* = - nullptr> - void assign(const expected_operations_base& rhs) noexcept { + detail::enable_if_t::value> + * = nullptr> + void assign(const expected_operations_base &rhs) noexcept { if (!this->m_has_val && rhs.m_has_val) { geterr().~unexpected(); construct(rhs.get()); @@ -2363,9 +2364,9 @@ struct expected_operations_base : expected_storage_base { // `T`, then no-throw move it into place if the copy was successful. template ::value && - std::is_nothrow_move_constructible::value>* = - nullptr> - void assign(const expected_operations_base& rhs) noexcept { + std::is_nothrow_move_constructible::value> + * = nullptr> + void assign(const expected_operations_base &rhs) noexcept { if (!this->m_has_val && rhs.m_has_val) { T tmp = rhs.get(); geterr().~unexpected(); @@ -2381,10 +2382,10 @@ struct expected_operations_base : expected_storage_base { // then we move the old unexpected value back into place before rethrowing the // exception. template ::value && - !std::is_nothrow_move_constructible::value>* = nullptr> - void assign(const expected_operations_base& rhs) { + detail::enable_if_t::value && + !std::is_nothrow_move_constructible::value> + * = nullptr> + void assign(const expected_operations_base &rhs) { if (!this->m_has_val && rhs.m_has_val) { auto tmp = std::move(geterr()); geterr().~unexpected(); @@ -2406,9 +2407,9 @@ struct expected_operations_base : expected_storage_base { // These overloads do the same as above, but for rvalues template ::value>* = - nullptr> - void assign(expected_operations_base&& rhs) noexcept { + detail::enable_if_t::value> + * = nullptr> + void assign(expected_operations_base &&rhs) noexcept { if (!this->m_has_val && rhs.m_has_val) { geterr().~unexpected(); construct(std::move(rhs).get()); @@ -2418,9 +2419,9 @@ struct expected_operations_base : expected_storage_base { } template ::value>* = nullptr> - void assign(expected_operations_base&& rhs) { + detail::enable_if_t::value> + * = nullptr> + void assign(expected_operations_base &&rhs) { if (!this->m_has_val && rhs.m_has_val) { auto tmp = std::move(geterr()); geterr().~unexpected(); @@ -2442,7 +2443,7 @@ struct expected_operations_base : expected_storage_base { #else // If exceptions are disabled then we can just copy-construct - void assign(const expected_operations_base& rhs) noexcept { + void assign(const expected_operations_base &rhs) noexcept { if (!this->m_has_val && rhs.m_has_val) { geterr().~unexpected(); construct(rhs.get()); @@ -2451,7 +2452,7 @@ struct expected_operations_base : expected_storage_base { } } - void assign(expected_operations_base&& rhs) noexcept { + void assign(expected_operations_base &&rhs) noexcept { if (!this->m_has_val && rhs.m_has_val) { geterr().~unexpected(); construct(std::move(rhs).get()); @@ -2464,7 +2465,7 @@ struct expected_operations_base : expected_storage_base { // The common part of move/copy assigning template - void assign_common(Rhs&& rhs) { + void assign_common(Rhs &&rhs) { if (this->m_has_val) { if (rhs.m_has_val) { get() = std::forward(rhs).get(); @@ -2481,22 +2482,22 @@ struct expected_operations_base : expected_storage_base { bool has_value() const { return this->m_has_val; } - TL_EXPECTED_11_CONSTEXPR T& get() & { return this->m_val; } - constexpr const T& get() const& { return this->m_val; } - TL_EXPECTED_11_CONSTEXPR T&& get() && { return std::move(this->m_val); } + TL_EXPECTED_11_CONSTEXPR T &get() & { return this->m_val; } + constexpr const T &get() const & { return this->m_val; } + TL_EXPECTED_11_CONSTEXPR T &&get() && { return std::move(this->m_val); } #ifndef TL_EXPECTED_NO_CONSTRR - constexpr const T&& get() const&& { return std::move(this->m_val); } + constexpr const T &&get() const && { return std::move(this->m_val); } #endif - TL_EXPECTED_11_CONSTEXPR unexpected& geterr() & { + TL_EXPECTED_11_CONSTEXPR unexpected &geterr() & { return this->m_unexpect; } - constexpr const unexpected& geterr() const& { return this->m_unexpect; } - TL_EXPECTED_11_CONSTEXPR unexpected&& geterr() && { + constexpr const unexpected &geterr() const & { return this->m_unexpect; } + TL_EXPECTED_11_CONSTEXPR unexpected &&geterr() && { return std::move(this->m_unexpect); } #ifndef TL_EXPECTED_NO_CONSTRR - constexpr const unexpected&& geterr() const&& { + constexpr const unexpected &&geterr() const && { return std::move(this->m_unexpect); } #endif @@ -2518,19 +2519,19 @@ struct expected_operations_base : expected_storage_base { // This function doesn't use its argument, but needs it so that code in // levels above this can work independently of whether T is void template - void construct_with(Rhs&&) noexcept { + void construct_with(Rhs &&) noexcept { this->m_has_val = true; } template - void construct_error(Args&&... args) noexcept { + void construct_error(Args &&...args) noexcept { new (std::addressof(this->m_unexpect)) unexpected(std::forward(args)...); this->m_has_val = false; } template - void assign(Rhs&& rhs) noexcept { + void assign(Rhs &&rhs) noexcept { if (!this->m_has_val) { if (rhs.m_has_val) { geterr().~unexpected(); @@ -2547,15 +2548,15 @@ struct expected_operations_base : expected_storage_base { bool has_value() const { return this->m_has_val; } - TL_EXPECTED_11_CONSTEXPR unexpected& geterr() & { + TL_EXPECTED_11_CONSTEXPR unexpected &geterr() & { return this->m_unexpect; } - constexpr const unexpected& geterr() const& { return this->m_unexpect; } - TL_EXPECTED_11_CONSTEXPR unexpected&& geterr() && { + constexpr const unexpected &geterr() const & { return this->m_unexpect; } + TL_EXPECTED_11_CONSTEXPR unexpected &&geterr() && { return std::move(this->m_unexpect); } #ifndef TL_EXPECTED_NO_CONSTRR - constexpr const unexpected&& geterr() const&& { + constexpr const unexpected &&geterr() const && { return std::move(this->m_unexpect); } #endif @@ -2568,8 +2569,9 @@ struct expected_operations_base : expected_storage_base { // This class manages conditionally having a trivial copy constructor // This specialization is for when T and E are trivially copy constructible template :: - value&& TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(E)::value> + bool = is_void_or::value && + TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(E)::value> struct expected_copy_base : expected_operations_base { using expected_operations_base::expected_operations_base; }; @@ -2580,7 +2582,7 @@ struct expected_copy_base : expected_operations_base { using expected_operations_base::expected_operations_base; expected_copy_base() = default; - expected_copy_base(const expected_copy_base& rhs) + expected_copy_base(const expected_copy_base &rhs) : expected_operations_base(no_init) { if (rhs.has_value()) { this->construct_with(rhs); @@ -2589,9 +2591,9 @@ struct expected_copy_base : expected_operations_base { } } - expected_copy_base(expected_copy_base&& rhs) = default; - expected_copy_base& operator=(const expected_copy_base& rhs) = default; - expected_copy_base& operator=(expected_copy_base&& rhs) = default; + expected_copy_base(expected_copy_base &&rhs) = default; + expected_copy_base &operator=(const expected_copy_base &rhs) = default; + expected_copy_base &operator=(expected_copy_base &&rhs) = default; }; // This class manages conditionally having a trivial move constructor @@ -2601,7 +2603,8 @@ struct expected_copy_base : expected_operations_base { // move constructible #ifndef TL_EXPECTED_GCC49 template >::value&& + bool = + is_void_or>::value && std::is_trivially_move_constructible::value> struct expected_move_base : expected_copy_base { using expected_copy_base::expected_copy_base; @@ -2615,9 +2618,9 @@ struct expected_move_base : expected_copy_base { using expected_copy_base::expected_copy_base; expected_move_base() = default; - expected_move_base(const expected_move_base& rhs) = default; + expected_move_base(const expected_move_base &rhs) = default; - expected_move_base(expected_move_base&& rhs) noexcept( + expected_move_base(expected_move_base &&rhs) noexcept( std::is_nothrow_move_constructible::value) : expected_copy_base(no_init) { if (rhs.has_value()) { @@ -2626,19 +2629,21 @@ struct expected_move_base : expected_copy_base { this->construct_error(std::move(rhs.geterr())); } } - expected_move_base& operator=(const expected_move_base& rhs) = default; - expected_move_base& operator=(expected_move_base&& rhs) = default; + expected_move_base &operator=(const expected_move_base &rhs) = default; + expected_move_base &operator=(expected_move_base &&rhs) = default; }; // This class manages conditionally having a trivial copy assignment operator -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> +template < + class T, class E, + bool = + is_void_or< + T, conjunction>::value && + TL_EXPECTED_IS_TRIVIALLY_COPY_ASSIGNABLE(E)::value && + TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(E)::value && + TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(E)::value> struct expected_copy_assign_base : expected_move_base { using expected_move_base::expected_move_base; }; @@ -2648,14 +2653,14 @@ struct expected_copy_assign_base : expected_move_base { using expected_move_base::expected_move_base; expected_copy_assign_base() = default; - expected_copy_assign_base(const expected_copy_assign_base& rhs) = default; + expected_copy_assign_base(const expected_copy_assign_base &rhs) = default; - expected_copy_assign_base(expected_copy_assign_base&& rhs) = default; - expected_copy_assign_base& operator=(const expected_copy_assign_base& rhs) { + expected_copy_assign_base(expected_copy_assign_base &&rhs) = default; + expected_copy_assign_base &operator=(const expected_copy_assign_base &rhs) { this->assign(rhs); return *this; } - expected_copy_assign_base& operator=(expected_copy_assign_base&& rhs) = + expected_copy_assign_base &operator=(expected_copy_assign_base &&rhs) = default; }; @@ -2665,14 +2670,15 @@ struct expected_copy_assign_base : expected_move_base { // to make do with a non-trivial move assignment operator even if T is trivially // move assignable #ifndef TL_EXPECTED_GCC49 -template , - std::is_trivially_move_constructible, - std::is_trivially_move_assignable>>:: - value&& std::is_trivially_destructible::value&& - std::is_trivially_move_constructible::value&& - std::is_trivially_move_assignable::value> +template < + class T, class E, + bool = is_void_or< + T, conjunction, + std::is_trivially_move_constructible, + std::is_trivially_move_assignable>>::value && + std::is_trivially_destructible::value && + std::is_trivially_move_constructible::value && + std::is_trivially_move_assignable::value> struct expected_move_assign_base : expected_copy_assign_base { using expected_copy_assign_base::expected_copy_assign_base; }; @@ -2687,17 +2693,17 @@ struct expected_move_assign_base using expected_copy_assign_base::expected_copy_assign_base; expected_move_assign_base() = default; - expected_move_assign_base(const expected_move_assign_base& rhs) = default; + expected_move_assign_base(const expected_move_assign_base &rhs) = default; - expected_move_assign_base(expected_move_assign_base&& rhs) = default; + expected_move_assign_base(expected_move_assign_base &&rhs) = default; - expected_move_assign_base& operator=(const expected_move_assign_base& rhs) = + expected_move_assign_base &operator=(const expected_move_assign_base &rhs) = default; - expected_move_assign_base& - operator=(expected_move_assign_base&& rhs) noexcept( - std::is_nothrow_move_constructible::value&& - std::is_nothrow_move_assignable::value) { + expected_move_assign_base &operator=( + expected_move_assign_base + &&rhs) noexcept(std::is_nothrow_move_constructible::value && + std::is_nothrow_move_assignable::value) { this->assign(std::move(rhs)); return *this; } @@ -2712,44 +2718,44 @@ template ::value)> struct expected_delete_ctor_base { expected_delete_ctor_base() = default; - expected_delete_ctor_base(const expected_delete_ctor_base&) = default; - expected_delete_ctor_base(expected_delete_ctor_base&&) noexcept = default; - expected_delete_ctor_base& operator=(const expected_delete_ctor_base&) = + expected_delete_ctor_base(const expected_delete_ctor_base &) = default; + expected_delete_ctor_base(expected_delete_ctor_base &&) noexcept = default; + expected_delete_ctor_base &operator=(const expected_delete_ctor_base &) = default; - expected_delete_ctor_base& operator=(expected_delete_ctor_base&&) noexcept = + expected_delete_ctor_base &operator=(expected_delete_ctor_base &&) noexcept = default; }; template struct expected_delete_ctor_base { expected_delete_ctor_base() = default; - expected_delete_ctor_base(const expected_delete_ctor_base&) = default; - expected_delete_ctor_base(expected_delete_ctor_base&&) noexcept = delete; - expected_delete_ctor_base& operator=(const expected_delete_ctor_base&) = + expected_delete_ctor_base(const expected_delete_ctor_base &) = default; + expected_delete_ctor_base(expected_delete_ctor_base &&) noexcept = delete; + expected_delete_ctor_base &operator=(const expected_delete_ctor_base &) = default; - expected_delete_ctor_base& operator=(expected_delete_ctor_base&&) noexcept = + expected_delete_ctor_base &operator=(expected_delete_ctor_base &&) noexcept = default; }; template struct expected_delete_ctor_base { expected_delete_ctor_base() = default; - expected_delete_ctor_base(const expected_delete_ctor_base&) = delete; - expected_delete_ctor_base(expected_delete_ctor_base&&) noexcept = default; - expected_delete_ctor_base& operator=(const expected_delete_ctor_base&) = + expected_delete_ctor_base(const expected_delete_ctor_base &) = delete; + expected_delete_ctor_base(expected_delete_ctor_base &&) noexcept = default; + expected_delete_ctor_base &operator=(const expected_delete_ctor_base &) = default; - expected_delete_ctor_base& operator=(expected_delete_ctor_base&&) noexcept = + expected_delete_ctor_base &operator=(expected_delete_ctor_base &&) noexcept = default; }; template struct expected_delete_ctor_base { expected_delete_ctor_base() = default; - expected_delete_ctor_base(const expected_delete_ctor_base&) = delete; - expected_delete_ctor_base(expected_delete_ctor_base&&) noexcept = delete; - expected_delete_ctor_base& operator=(const expected_delete_ctor_base&) = + expected_delete_ctor_base(const expected_delete_ctor_base &) = delete; + expected_delete_ctor_base(expected_delete_ctor_base &&) noexcept = delete; + expected_delete_ctor_base &operator=(const expected_delete_ctor_base &) = default; - expected_delete_ctor_base& operator=(expected_delete_ctor_base&&) noexcept = + expected_delete_ctor_base &operator=(expected_delete_ctor_base &&) noexcept = default; }; @@ -2767,45 +2773,49 @@ template ::value)> struct expected_delete_assign_base { expected_delete_assign_base() = default; - expected_delete_assign_base(const expected_delete_assign_base&) = default; - expected_delete_assign_base(expected_delete_assign_base&&) noexcept = default; - expected_delete_assign_base& operator=(const expected_delete_assign_base&) = + expected_delete_assign_base(const expected_delete_assign_base &) = default; + expected_delete_assign_base(expected_delete_assign_base &&) noexcept = + default; + expected_delete_assign_base &operator=(const expected_delete_assign_base &) = default; - expected_delete_assign_base& operator=( - expected_delete_assign_base&&) noexcept = default; + expected_delete_assign_base &operator=( + expected_delete_assign_base &&) noexcept = default; }; template struct expected_delete_assign_base { expected_delete_assign_base() = default; - expected_delete_assign_base(const expected_delete_assign_base&) = default; - expected_delete_assign_base(expected_delete_assign_base&&) noexcept = default; - expected_delete_assign_base& operator=(const expected_delete_assign_base&) = + expected_delete_assign_base(const expected_delete_assign_base &) = default; + expected_delete_assign_base(expected_delete_assign_base &&) noexcept = default; - expected_delete_assign_base& operator=( - expected_delete_assign_base&&) noexcept = delete; + expected_delete_assign_base &operator=(const expected_delete_assign_base &) = + default; + expected_delete_assign_base &operator=( + expected_delete_assign_base &&) noexcept = delete; }; template struct expected_delete_assign_base { expected_delete_assign_base() = default; - expected_delete_assign_base(const expected_delete_assign_base&) = default; - expected_delete_assign_base(expected_delete_assign_base&&) noexcept = default; - expected_delete_assign_base& operator=(const expected_delete_assign_base&) = + expected_delete_assign_base(const expected_delete_assign_base &) = default; + expected_delete_assign_base(expected_delete_assign_base &&) noexcept = + default; + expected_delete_assign_base &operator=(const expected_delete_assign_base &) = delete; - expected_delete_assign_base& operator=( - expected_delete_assign_base&&) noexcept = default; + expected_delete_assign_base &operator=( + expected_delete_assign_base &&) noexcept = default; }; template struct expected_delete_assign_base { expected_delete_assign_base() = default; - expected_delete_assign_base(const expected_delete_assign_base&) = default; - expected_delete_assign_base(expected_delete_assign_base&&) noexcept = default; - expected_delete_assign_base& operator=(const expected_delete_assign_base&) = + expected_delete_assign_base(const expected_delete_assign_base &) = default; + expected_delete_assign_base(expected_delete_assign_base &&) noexcept = + default; + expected_delete_assign_base &operator=(const expected_delete_assign_base &) = delete; - expected_delete_assign_base& operator=( - expected_delete_assign_base&&) noexcept = delete; + expected_delete_assign_base &operator=( + expected_delete_assign_base &&) noexcept = delete; }; // This is needed to be able to construct the expected_default_ctor_base which @@ -2823,13 +2833,13 @@ template struct expected_default_ctor_base { constexpr expected_default_ctor_base() noexcept = delete; constexpr expected_default_ctor_base( - expected_default_ctor_base const&) noexcept = default; - constexpr expected_default_ctor_base(expected_default_ctor_base&&) noexcept = - default; - expected_default_ctor_base& operator=( - expected_default_ctor_base const&) noexcept = default; - expected_default_ctor_base& operator=(expected_default_ctor_base&&) noexcept = + expected_default_ctor_base const &) noexcept = default; + constexpr expected_default_ctor_base(expected_default_ctor_base &&) noexcept = default; + expected_default_ctor_base &operator=( + expected_default_ctor_base const &) noexcept = default; + expected_default_ctor_base &operator=( + expected_default_ctor_base &&) noexcept = default; constexpr explicit expected_default_ctor_base(default_constructor_tag) {} }; @@ -2856,14 +2866,14 @@ class bad_expected_access : public std::exception { public: explicit bad_expected_access(E e) : m_val(std::move(e)) {} - virtual const char* what() const noexcept override { + virtual const char *what() const noexcept override { return "Bad expected access"; } - const E& error() const& { return m_val; } - E& error() & { return m_val; } - const E&& error() const&& { return std::move(m_val); } - E&& error() && { return std::move(m_val); } + const E &error() const & { return m_val; } + E &error() & { return m_val; } + const E &&error() const && { return std::move(m_val); } + E &&error() && { return std::move(m_val); } private: E m_val; @@ -2891,26 +2901,26 @@ class expected : private detail::expected_move_assign_base, "T must not be unexpected"); static_assert(!std::is_reference::value, "E must not be a reference"); - T* valptr() { return std::addressof(this->m_val); } - const T* valptr() const { return std::addressof(this->m_val); } - unexpected* errptr() { return std::addressof(this->m_unexpect); } - const unexpected* errptr() const { + T *valptr() { return std::addressof(this->m_val); } + const T *valptr() const { return std::addressof(this->m_val); } + unexpected *errptr() { return std::addressof(this->m_unexpect); } + const unexpected *errptr() const { return std::addressof(this->m_unexpect); } template ::value>* = nullptr> - TL_EXPECTED_11_CONSTEXPR U& val() { + detail::enable_if_t::value> * = nullptr> + TL_EXPECTED_11_CONSTEXPR U &val() { return this->m_val; } - TL_EXPECTED_11_CONSTEXPR unexpected& err() { return this->m_unexpect; } + TL_EXPECTED_11_CONSTEXPR unexpected &err() { return this->m_unexpect; } template ::value>* = nullptr> - constexpr const U& val() const { + detail::enable_if_t::value> * = nullptr> + constexpr const U &val() const { return this->m_val; } - constexpr const unexpected& err() const { return this->m_unexpect; } + constexpr const unexpected &err() const { return this->m_unexpect; } using impl_base = detail::expected_move_assign_base; using ctor_base = detail::expected_default_ctor_base; @@ -2923,46 +2933,46 @@ class expected : private detail::expected_move_assign_base, #if defined(TL_EXPECTED_CXX14) && !defined(TL_EXPECTED_GCC49) && \ !defined(TL_EXPECTED_GCC54) && !defined(TL_EXPECTED_GCC55) template - TL_EXPECTED_11_CONSTEXPR auto and_then(F&& f) & { + TL_EXPECTED_11_CONSTEXPR auto and_then(F &&f) & { return and_then_impl(*this, std::forward(f)); } template - TL_EXPECTED_11_CONSTEXPR auto and_then(F&& f) && { + TL_EXPECTED_11_CONSTEXPR auto and_then(F &&f) && { return and_then_impl(std::move(*this), std::forward(f)); } template - constexpr auto and_then(F&& f) const& { + constexpr auto and_then(F &&f) const & { return and_then_impl(*this, std::forward(f)); } #ifndef TL_EXPECTED_NO_CONSTRR template - constexpr auto and_then(F&& f) const&& { + constexpr auto and_then(F &&f) const && { return and_then_impl(std::move(*this), std::forward(f)); } #endif #else template - TL_EXPECTED_11_CONSTEXPR auto and_then(F&& f) & -> decltype( - and_then_impl(std::declval(), std::forward(f))) { + TL_EXPECTED_11_CONSTEXPR auto and_then(F &&f) & -> decltype(and_then_impl( + std::declval(), std::forward(f))) { return and_then_impl(*this, std::forward(f)); } template - TL_EXPECTED_11_CONSTEXPR auto and_then(F&& f) && -> decltype( - and_then_impl(std::declval(), std::forward(f))) { + TL_EXPECTED_11_CONSTEXPR auto and_then(F &&f) && -> decltype(and_then_impl( + std::declval(), std::forward(f))) { return and_then_impl(std::move(*this), std::forward(f)); } template - constexpr auto and_then(F&& f) const& -> decltype( - and_then_impl(std::declval(), std::forward(f))) { + constexpr auto and_then(F &&f) const & -> decltype(and_then_impl( + std::declval(), std::forward(f))) { return and_then_impl(*this, std::forward(f)); } #ifndef TL_EXPECTED_NO_CONSTRR template - constexpr auto and_then(F&& f) const&& -> decltype( - and_then_impl(std::declval(), std::forward(f))) { + constexpr auto and_then(F &&f) const && -> decltype(and_then_impl( + std::declval(), std::forward(f))) { return and_then_impl(std::move(*this), std::forward(f)); } #endif @@ -2971,46 +2981,46 @@ class expected : private detail::expected_move_assign_base, #if defined(TL_EXPECTED_CXX14) && !defined(TL_EXPECTED_GCC49) && \ !defined(TL_EXPECTED_GCC54) && !defined(TL_EXPECTED_GCC55) template - TL_EXPECTED_11_CONSTEXPR auto map(F&& f) & { + TL_EXPECTED_11_CONSTEXPR auto map(F &&f) & { return expected_map_impl(*this, std::forward(f)); } template - TL_EXPECTED_11_CONSTEXPR auto map(F&& f) && { + TL_EXPECTED_11_CONSTEXPR auto map(F &&f) && { return expected_map_impl(std::move(*this), std::forward(f)); } template - constexpr auto map(F&& f) const& { + constexpr auto map(F &&f) const & { return expected_map_impl(*this, std::forward(f)); } template - constexpr auto map(F&& f) const&& { + constexpr auto map(F &&f) const && { return expected_map_impl(std::move(*this), std::forward(f)); } #else template - TL_EXPECTED_11_CONSTEXPR decltype(expected_map_impl(std::declval(), - std::declval())) - map(F&& f) & { + TL_EXPECTED_11_CONSTEXPR decltype(expected_map_impl( + std::declval(), std::declval())) + map(F &&f) & { return expected_map_impl(*this, std::forward(f)); } template TL_EXPECTED_11_CONSTEXPR decltype(expected_map_impl(std::declval(), - std::declval())) - map(F&& f) && { + std::declval())) + map(F &&f) && { return expected_map_impl(std::move(*this), std::forward(f)); } template - constexpr decltype(expected_map_impl(std::declval(), - std::declval())) - map(F&& f) const& { + constexpr decltype(expected_map_impl(std::declval(), + std::declval())) + map(F &&f) const & { return expected_map_impl(*this, std::forward(f)); } #ifndef TL_EXPECTED_NO_CONSTRR template - constexpr decltype(expected_map_impl(std::declval(), - std::declval())) - map(F&& f) const&& { + constexpr decltype(expected_map_impl(std::declval(), + std::declval())) + map(F &&f) const && { return expected_map_impl(std::move(*this), std::forward(f)); } #endif @@ -3019,46 +3029,46 @@ class expected : private detail::expected_move_assign_base, #if defined(TL_EXPECTED_CXX14) && !defined(TL_EXPECTED_GCC49) && \ !defined(TL_EXPECTED_GCC54) && !defined(TL_EXPECTED_GCC55) template - TL_EXPECTED_11_CONSTEXPR auto transform(F&& f) & { + TL_EXPECTED_11_CONSTEXPR auto transform(F &&f) & { return expected_map_impl(*this, std::forward(f)); } template - TL_EXPECTED_11_CONSTEXPR auto transform(F&& f) && { + TL_EXPECTED_11_CONSTEXPR auto transform(F &&f) && { return expected_map_impl(std::move(*this), std::forward(f)); } template - constexpr auto transform(F&& f) const& { + constexpr auto transform(F &&f) const & { return expected_map_impl(*this, std::forward(f)); } template - constexpr auto transform(F&& f) const&& { + constexpr auto transform(F &&f) const && { return expected_map_impl(std::move(*this), std::forward(f)); } #else template - TL_EXPECTED_11_CONSTEXPR decltype(expected_map_impl(std::declval(), - std::declval())) - transform(F&& f) & { + TL_EXPECTED_11_CONSTEXPR decltype(expected_map_impl( + std::declval(), std::declval())) + transform(F &&f) & { return expected_map_impl(*this, std::forward(f)); } template TL_EXPECTED_11_CONSTEXPR decltype(expected_map_impl(std::declval(), - std::declval())) - transform(F&& f) && { + std::declval())) + transform(F &&f) && { return expected_map_impl(std::move(*this), std::forward(f)); } template - constexpr decltype(expected_map_impl(std::declval(), - std::declval())) - transform(F&& f) const& { + constexpr decltype(expected_map_impl(std::declval(), + std::declval())) + transform(F &&f) const & { return expected_map_impl(*this, std::forward(f)); } #ifndef TL_EXPECTED_NO_CONSTRR template - constexpr decltype(expected_map_impl(std::declval(), - std::declval())) - transform(F&& f) const&& { + constexpr decltype(expected_map_impl(std::declval(), + std::declval())) + transform(F &&f) const && { return expected_map_impl(std::move(*this), std::forward(f)); } #endif @@ -3067,46 +3077,46 @@ class expected : private detail::expected_move_assign_base, #if defined(TL_EXPECTED_CXX14) && !defined(TL_EXPECTED_GCC49) && \ !defined(TL_EXPECTED_GCC54) && !defined(TL_EXPECTED_GCC55) template - TL_EXPECTED_11_CONSTEXPR auto map_error(F&& f) & { + TL_EXPECTED_11_CONSTEXPR auto map_error(F &&f) & { return map_error_impl(*this, std::forward(f)); } template - TL_EXPECTED_11_CONSTEXPR auto map_error(F&& f) && { + TL_EXPECTED_11_CONSTEXPR auto map_error(F &&f) && { return map_error_impl(std::move(*this), std::forward(f)); } template - constexpr auto map_error(F&& f) const& { + constexpr auto map_error(F &&f) const & { return map_error_impl(*this, std::forward(f)); } template - constexpr auto map_error(F&& f) const&& { + constexpr auto map_error(F &&f) const && { return map_error_impl(std::move(*this), std::forward(f)); } #else template - TL_EXPECTED_11_CONSTEXPR decltype(map_error_impl(std::declval(), - std::declval())) - map_error(F&& f) & { + TL_EXPECTED_11_CONSTEXPR decltype(map_error_impl(std::declval(), + std::declval())) + map_error(F &&f) & { return map_error_impl(*this, std::forward(f)); } template - TL_EXPECTED_11_CONSTEXPR decltype(map_error_impl(std::declval(), - std::declval())) - map_error(F&& f) && { + TL_EXPECTED_11_CONSTEXPR decltype(map_error_impl(std::declval(), + std::declval())) + map_error(F &&f) && { return map_error_impl(std::move(*this), std::forward(f)); } template - constexpr decltype(map_error_impl(std::declval(), - std::declval())) - map_error(F&& f) const& { + constexpr decltype(map_error_impl(std::declval(), + std::declval())) + map_error(F &&f) const & { return map_error_impl(*this, std::forward(f)); } #ifndef TL_EXPECTED_NO_CONSTRR template - constexpr decltype(map_error_impl(std::declval(), - std::declval())) - map_error(F&& f) const&& { + constexpr decltype(map_error_impl(std::declval(), + std::declval())) + map_error(F &&f) const && { return map_error_impl(std::move(*this), std::forward(f)); } #endif @@ -3114,147 +3124,149 @@ class expected : private detail::expected_move_assign_base, #if defined(TL_EXPECTED_CXX14) && !defined(TL_EXPECTED_GCC49) && \ !defined(TL_EXPECTED_GCC54) && !defined(TL_EXPECTED_GCC55) template - TL_EXPECTED_11_CONSTEXPR auto transform_error(F&& f) & { + TL_EXPECTED_11_CONSTEXPR auto transform_error(F &&f) & { return map_error_impl(*this, std::forward(f)); } template - TL_EXPECTED_11_CONSTEXPR auto transform_error(F&& f) && { + TL_EXPECTED_11_CONSTEXPR auto transform_error(F &&f) && { return map_error_impl(std::move(*this), std::forward(f)); } template - constexpr auto transform_error(F&& f) const& { + constexpr auto transform_error(F &&f) const & { return map_error_impl(*this, std::forward(f)); } template - constexpr auto transform_error(F&& f) const&& { + constexpr auto transform_error(F &&f) const && { return map_error_impl(std::move(*this), std::forward(f)); } #else template - TL_EXPECTED_11_CONSTEXPR decltype(map_error_impl(std::declval(), - std::declval())) - transform_error(F&& f) & { + TL_EXPECTED_11_CONSTEXPR decltype(map_error_impl(std::declval(), + std::declval())) + transform_error(F &&f) & { return map_error_impl(*this, std::forward(f)); } template - TL_EXPECTED_11_CONSTEXPR decltype(map_error_impl(std::declval(), - std::declval())) - transform_error(F&& f) && { + TL_EXPECTED_11_CONSTEXPR decltype(map_error_impl(std::declval(), + std::declval())) + transform_error(F &&f) && { return map_error_impl(std::move(*this), std::forward(f)); } template - constexpr decltype(map_error_impl(std::declval(), - std::declval())) - transform_error(F&& f) const& { + constexpr decltype(map_error_impl(std::declval(), + std::declval())) + transform_error(F &&f) const & { return map_error_impl(*this, std::forward(f)); } #ifndef TL_EXPECTED_NO_CONSTRR template - constexpr decltype(map_error_impl(std::declval(), - std::declval())) - transform_error(F&& f) const&& { + constexpr decltype(map_error_impl(std::declval(), + std::declval())) + transform_error(F &&f) const && { return map_error_impl(std::move(*this), std::forward(f)); } #endif #endif template - expected TL_EXPECTED_11_CONSTEXPR or_else(F&& f) & { + expected TL_EXPECTED_11_CONSTEXPR or_else(F &&f) & { return or_else_impl(*this, std::forward(f)); } template - expected TL_EXPECTED_11_CONSTEXPR or_else(F&& f) && { + expected TL_EXPECTED_11_CONSTEXPR or_else(F &&f) && { return or_else_impl(std::move(*this), std::forward(f)); } template - expected constexpr or_else(F&& f) const& { + expected constexpr or_else(F &&f) const & { return or_else_impl(*this, std::forward(f)); } #ifndef TL_EXPECTED_NO_CONSTRR template - expected constexpr or_else(F&& f) const&& { + expected constexpr or_else(F &&f) const && { return or_else_impl(std::move(*this), std::forward(f)); } #endif constexpr expected() = default; - constexpr expected(const expected& rhs) = default; - constexpr expected(expected&& rhs) = default; - expected& operator=(const expected& rhs) = default; - expected& operator=(expected&& rhs) = default; + constexpr expected(const expected &rhs) = default; + constexpr expected(expected &&rhs) = default; + expected &operator=(const expected &rhs) = default; + expected &operator=(expected &&rhs) = default; template ::value>* = + detail::enable_if_t::value> * = nullptr> - constexpr expected(in_place_t, Args&&... args) + constexpr expected(in_place_t, Args &&...args) : impl_base(in_place, std::forward(args)...), ctor_base(detail::default_constructor_tag{}) {} template &, Args&&...>::value>* = nullptr> - constexpr expected(in_place_t, std::initializer_list il, Args&&... args) + T, std::initializer_list &, Args &&...>::value> * = nullptr> + constexpr expected(in_place_t, std::initializer_list il, Args &&...args) : impl_base(in_place, il, std::forward(args)...), ctor_base(detail::default_constructor_tag{}) {} - template < - class G = E, - detail::enable_if_t::value>* = nullptr, - detail::enable_if_t::value>* = nullptr> - explicit constexpr expected(const unexpected& e) + template ::value> * = + nullptr, + detail::enable_if_t::value> * = + nullptr> + explicit constexpr expected(const unexpected &e) : impl_base(unexpect, e.value()), ctor_base(detail::default_constructor_tag{}) {} template < class G = E, - detail::enable_if_t::value>* = nullptr, - detail::enable_if_t::value>* = nullptr> - constexpr expected(unexpected const& e) + detail::enable_if_t::value> * = + nullptr, + detail::enable_if_t::value> * = nullptr> + constexpr expected(unexpected const &e) : impl_base(unexpect, e.value()), ctor_base(detail::default_constructor_tag{}) {} template < class G = E, - detail::enable_if_t::value>* = nullptr, - detail::enable_if_t::value>* = nullptr> - explicit constexpr expected(unexpected&& e) noexcept( - std::is_nothrow_constructible::value) + detail::enable_if_t::value> * = nullptr, + detail::enable_if_t::value> * = nullptr> + explicit constexpr expected(unexpected &&e) noexcept( + std::is_nothrow_constructible::value) : impl_base(unexpect, std::move(e.value())), ctor_base(detail::default_constructor_tag{}) {} template < class G = E, - detail::enable_if_t::value>* = nullptr, - detail::enable_if_t::value>* = nullptr> - constexpr expected(unexpected&& e) noexcept( - std::is_nothrow_constructible::value) + detail::enable_if_t::value> * = nullptr, + detail::enable_if_t::value> * = nullptr> + constexpr expected(unexpected &&e) noexcept( + std::is_nothrow_constructible::value) : impl_base(unexpect, std::move(e.value())), ctor_base(detail::default_constructor_tag{}) {} template ::value>* = + detail::enable_if_t::value> * = nullptr> - constexpr explicit expected(unexpect_t, Args&&... args) + constexpr explicit expected(unexpect_t, Args &&...args) : impl_base(unexpect, std::forward(args)...), ctor_base(detail::default_constructor_tag{}) {} template &, Args&&...>::value>* = nullptr> + E, std::initializer_list &, Args &&...>::value> * = nullptr> constexpr explicit expected(unexpect_t, std::initializer_list il, - Args&&... args) + Args &&...args) : impl_base(unexpect, il, std::forward(args)...), ctor_base(detail::default_constructor_tag{}) {} template ::value && - std::is_convertible::value)>* = + detail::enable_if_t::value && + std::is_convertible::value)> * = nullptr, - detail::expected_enable_from_other* = nullptr> - explicit TL_EXPECTED_11_CONSTEXPR expected(const expected& rhs) + detail::expected_enable_from_other + * = nullptr> + explicit TL_EXPECTED_11_CONSTEXPR expected(const expected &rhs) : ctor_base(detail::default_constructor_tag{}) { if (rhs.has_value()) { this->construct(*rhs); @@ -3263,13 +3275,13 @@ class expected : private detail::expected_move_assign_base, } } - template < - class U, class G, - detail::enable_if_t<(std::is_convertible::value && - std::is_convertible::value)>* = nullptr, - detail::expected_enable_from_other* = - nullptr> - TL_EXPECTED_11_CONSTEXPR expected(const expected& rhs) + template ::value && + std::is_convertible::value)> * = + nullptr, + detail::expected_enable_from_other + * = nullptr> + TL_EXPECTED_11_CONSTEXPR expected(const expected &rhs) : ctor_base(detail::default_constructor_tag{}) { if (rhs.has_value()) { this->construct(*rhs); @@ -3280,10 +3292,10 @@ class expected : private detail::expected_move_assign_base, template < class U, class G, - detail::enable_if_t::value && - std::is_convertible::value)>* = nullptr, - detail::expected_enable_from_other* = nullptr> - explicit TL_EXPECTED_11_CONSTEXPR expected(expected&& rhs) + detail::enable_if_t::value && + std::is_convertible::value)> * = nullptr, + detail::expected_enable_from_other * = nullptr> + explicit TL_EXPECTED_11_CONSTEXPR expected(expected &&rhs) : ctor_base(detail::default_constructor_tag{}) { if (rhs.has_value()) { this->construct(std::move(*rhs)); @@ -3294,10 +3306,10 @@ class expected : private detail::expected_move_assign_base, template < class U, class G, - detail::enable_if_t<(std::is_convertible::value && - std::is_convertible::value)>* = nullptr, - detail::expected_enable_from_other* = nullptr> - TL_EXPECTED_11_CONSTEXPR expected(expected&& rhs) + detail::enable_if_t<(std::is_convertible::value && + std::is_convertible::value)> * = nullptr, + detail::expected_enable_from_other * = nullptr> + TL_EXPECTED_11_CONSTEXPR expected(expected &&rhs) : ctor_base(detail::default_constructor_tag{}) { if (rhs.has_value()) { this->construct(std::move(*rhs)); @@ -3306,31 +3318,33 @@ class expected : private detail::expected_move_assign_base, } } - template ::value>* = nullptr, - detail::expected_enable_forward_value* = nullptr> - explicit TL_EXPECTED_MSVC2015_CONSTEXPR expected(U&& v) + template < + class U = T, + detail::enable_if_t::value> * = nullptr, + detail::expected_enable_forward_value * = nullptr> + explicit TL_EXPECTED_MSVC2015_CONSTEXPR expected(U &&v) : expected(in_place, std::forward(v)) {} - template ::value>* = nullptr, - detail::expected_enable_forward_value* = nullptr> - TL_EXPECTED_MSVC2015_CONSTEXPR expected(U&& v) + template < + class U = T, + detail::enable_if_t::value> * = nullptr, + detail::expected_enable_forward_value * = nullptr> + TL_EXPECTED_MSVC2015_CONSTEXPR expected(U &&v) : expected(in_place, std::forward(v)) {} template < class U = T, class G = T, - detail::enable_if_t::value>* = + detail::enable_if_t::value> * = nullptr, - detail::enable_if_t::value>* = nullptr, + detail::enable_if_t::value> * = nullptr, detail::enable_if_t< (!std::is_same, detail::decay_t>::value && !detail::conjunction, std::is_same>>::value && std::is_constructible::value && - std::is_assignable::value && - std::is_nothrow_move_constructible::value)>* = nullptr> - expected& operator=(U&& v) { + std::is_assignable::value && + std::is_nothrow_move_constructible::value)> * = nullptr> + expected &operator=(U &&v) { if (has_value()) { val() = std::forward(v); } else { @@ -3344,17 +3358,17 @@ class expected : private detail::expected_move_assign_base, template < class U = T, class G = T, - detail::enable_if_t::value>* = + detail::enable_if_t::value> * = nullptr, - detail::enable_if_t::value>* = nullptr, + detail::enable_if_t::value> * = nullptr, detail::enable_if_t< (!std::is_same, detail::decay_t>::value && !detail::conjunction, std::is_same>>::value && std::is_constructible::value && - std::is_assignable::value && - std::is_nothrow_move_constructible::value)>* = nullptr> - expected& operator=(U&& v) { + std::is_assignable::value && + std::is_nothrow_move_constructible::value)> * = nullptr> + expected &operator=(U &&v) { if (has_value()) { val() = std::forward(v); } else { @@ -3380,8 +3394,8 @@ class expected : private detail::expected_move_assign_base, template ::value && - std::is_assignable::value>* = nullptr> - expected& operator=(const unexpected& rhs) { + std::is_assignable::value> * = nullptr> + expected &operator=(const unexpected &rhs) { if (!has_value()) { err() = rhs; } else { @@ -3395,8 +3409,8 @@ class expected : private detail::expected_move_assign_base, template ::value && - std::is_move_assignable::value>* = nullptr> - expected& operator=(unexpected&& rhs) noexcept { + std::is_move_assignable::value> * = nullptr> + expected &operator=(unexpected &&rhs) noexcept { if (!has_value()) { err() = std::move(rhs); } else { @@ -3409,8 +3423,8 @@ class expected : private detail::expected_move_assign_base, } template ::value>* = nullptr> - void emplace(Args&&... args) { + T, Args &&...>::value> * = nullptr> + void emplace(Args &&...args) { if (has_value()) { val().~T(); } else { @@ -3421,8 +3435,8 @@ class expected : private detail::expected_move_assign_base, } template ::value>* = nullptr> - void emplace(Args&&... args) { + T, Args &&...>::value> * = nullptr> + void emplace(Args &&...args) { if (has_value()) { val().~T(); ::new (valptr()) T(std::forward(args)...); @@ -3447,8 +3461,8 @@ class expected : private detail::expected_move_assign_base, template &, Args&&...>::value>* = nullptr> - void emplace(std::initializer_list il, Args&&... args) { + T, std::initializer_list &, Args &&...>::value> * = nullptr> + void emplace(std::initializer_list il, Args &&...args) { if (has_value()) { T t(il, std::forward(args)...); val() = std::move(t); @@ -3461,8 +3475,8 @@ class expected : private detail::expected_move_assign_base, template &, Args&&...>::value>* = nullptr> - void emplace(std::initializer_list il, Args&&... args) { + T, std::initializer_list &, Args &&...>::value> * = nullptr> + void emplace(std::initializer_list il, Args &&...args) { if (has_value()) { T t(il, std::forward(args)...); val() = std::move(t); @@ -3493,30 +3507,30 @@ class expected : private detail::expected_move_assign_base, using e_is_nothrow_move_constructible = std::true_type; using move_constructing_e_can_throw = std::false_type; - void swap_where_both_have_value(expected& /*rhs*/, t_is_void) noexcept { + void swap_where_both_have_value(expected & /*rhs*/, t_is_void) noexcept { // swapping void is a no-op } - void swap_where_both_have_value(expected& rhs, t_is_not_void) { + void swap_where_both_have_value(expected &rhs, t_is_not_void) { using std::swap; swap(val(), rhs.val()); } - void swap_where_only_one_has_value(expected& rhs, t_is_void) noexcept( + void swap_where_only_one_has_value(expected &rhs, t_is_void) noexcept( std::is_nothrow_move_constructible::value) { ::new (errptr()) unexpected_type(std::move(rhs.err())); rhs.err().~unexpected_type(); std::swap(this->m_has_val, rhs.m_has_val); } - void swap_where_only_one_has_value(expected& rhs, t_is_not_void) { + void swap_where_only_one_has_value(expected &rhs, t_is_not_void) { swap_where_only_one_has_value_and_t_is_not_void( rhs, typename std::is_nothrow_move_constructible::type{}, typename std::is_nothrow_move_constructible::type{}); } void swap_where_only_one_has_value_and_t_is_not_void( - expected& rhs, t_is_nothrow_move_constructible, + expected &rhs, t_is_nothrow_move_constructible, e_is_nothrow_move_constructible) noexcept { auto temp = std::move(val()); val().~T(); @@ -3527,7 +3541,7 @@ class expected : private detail::expected_move_assign_base, } void swap_where_only_one_has_value_and_t_is_not_void( - expected& rhs, t_is_nothrow_move_constructible, + expected &rhs, t_is_nothrow_move_constructible, move_constructing_e_can_throw) { auto temp = std::move(val()); val().~T(); @@ -3550,7 +3564,7 @@ class expected : private detail::expected_move_assign_base, } void swap_where_only_one_has_value_and_t_is_not_void( - expected& rhs, move_constructing_t_can_throw, + expected &rhs, move_constructing_t_can_throw, e_is_nothrow_move_constructible) { auto temp = std::move(rhs.err()); rhs.err().~unexpected_type(); @@ -3578,11 +3592,10 @@ class expected : private detail::expected_move_assign_base, detail::is_swappable::value && (std::is_nothrow_move_constructible::value || std::is_nothrow_move_constructible::value)> - swap(expected& rhs) noexcept( - std::is_nothrow_move_constructible::value&& - detail::is_nothrow_swappable::value&& - std::is_nothrow_move_constructible::value&& - detail::is_nothrow_swappable::value) { + swap(expected &rhs) noexcept(std::is_nothrow_move_constructible::value && + detail::is_nothrow_swappable::value && + std::is_nothrow_move_constructible::value && + detail::is_nothrow_swappable::value) { if (has_value() && rhs.has_value()) { swap_where_both_have_value(rhs, typename std::is_void::type{}); } else if (!has_value() && rhs.has_value()) { @@ -3595,36 +3608,36 @@ class expected : private detail::expected_move_assign_base, } } - constexpr const T* operator->() const { + constexpr const T *operator->() const { TL_ASSERT(has_value()); return valptr(); } - TL_EXPECTED_11_CONSTEXPR T* operator->() { + TL_EXPECTED_11_CONSTEXPR T *operator->() { TL_ASSERT(has_value()); return valptr(); } template ::value>* = nullptr> - constexpr const U& operator*() const& { + detail::enable_if_t::value> * = nullptr> + constexpr const U &operator*() const & { TL_ASSERT(has_value()); return val(); } template ::value>* = nullptr> - TL_EXPECTED_11_CONSTEXPR U& operator*() & { + detail::enable_if_t::value> * = nullptr> + TL_EXPECTED_11_CONSTEXPR U &operator*() & { TL_ASSERT(has_value()); return val(); } template ::value>* = nullptr> - constexpr const U&& operator*() const&& { + detail::enable_if_t::value> * = nullptr> + constexpr const U &&operator*() const && { TL_ASSERT(has_value()); return std::move(val()); } template ::value>* = nullptr> - TL_EXPECTED_11_CONSTEXPR U&& operator*() && { + detail::enable_if_t::value> * = nullptr> + TL_EXPECTED_11_CONSTEXPR U &&operator*() && { TL_ASSERT(has_value()); return std::move(val()); } @@ -3633,62 +3646,62 @@ class expected : private detail::expected_move_assign_base, constexpr explicit operator bool() const noexcept { return this->m_has_val; } template ::value>* = nullptr> - TL_EXPECTED_11_CONSTEXPR const U& value() const& { + detail::enable_if_t::value> * = nullptr> + TL_EXPECTED_11_CONSTEXPR const U &value() const & { if (!has_value()) detail::throw_exception(bad_expected_access(err().value())); return val(); } template ::value>* = nullptr> - TL_EXPECTED_11_CONSTEXPR U& value() & { + detail::enable_if_t::value> * = nullptr> + TL_EXPECTED_11_CONSTEXPR U &value() & { if (!has_value()) detail::throw_exception(bad_expected_access(err().value())); return val(); } template ::value>* = nullptr> - TL_EXPECTED_11_CONSTEXPR const U&& value() const&& { + detail::enable_if_t::value> * = nullptr> + TL_EXPECTED_11_CONSTEXPR const U &&value() const && { if (!has_value()) detail::throw_exception(bad_expected_access(std::move(err()).value())); return std::move(val()); } template ::value>* = nullptr> - TL_EXPECTED_11_CONSTEXPR U&& value() && { + detail::enable_if_t::value> * = nullptr> + TL_EXPECTED_11_CONSTEXPR U &&value() && { if (!has_value()) detail::throw_exception(bad_expected_access(std::move(err()).value())); return std::move(val()); } - constexpr const E& error() const& { + constexpr const E &error() const & { TL_ASSERT(!has_value()); return err().value(); } - TL_EXPECTED_11_CONSTEXPR E& error() & { + TL_EXPECTED_11_CONSTEXPR E &error() & { TL_ASSERT(!has_value()); return err().value(); } - constexpr const E&& error() const&& { + constexpr const E &&error() const && { TL_ASSERT(!has_value()); return std::move(err().value()); } - TL_EXPECTED_11_CONSTEXPR E&& error() && { + TL_EXPECTED_11_CONSTEXPR E &&error() && { TL_ASSERT(!has_value()); return std::move(err().value()); } template - constexpr T value_or(U&& v) const& { + constexpr T value_or(U &&v) const & { static_assert(std::is_copy_constructible::value && - std::is_convertible::value, + std::is_convertible::value, "T must be copy-constructible and convertible to from U&&"); return bool(*this) ? **this : static_cast(std::forward(v)); } template - TL_EXPECTED_11_CONSTEXPR T value_or(U&& v) && { + TL_EXPECTED_11_CONSTEXPR T value_or(U &&v) && { static_assert(std::is_move_constructible::value && - std::is_convertible::value, + std::is_convertible::value, "T must be move-constructible and convertible to from U&&"); return bool(*this) ? std::move(**this) : static_cast(std::forward(v)); } @@ -3704,10 +3717,10 @@ using ret_t = expected>; #ifdef TL_EXPECTED_CXX14 template >::value>* = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval(), *std::declval()))> -constexpr auto and_then_impl(Exp&& exp, F&& f) { +constexpr auto and_then_impl(Exp &&exp, F &&f) { static_assert(detail::is_expected::value, "F must return an expected"); return exp.has_value() @@ -3716,9 +3729,9 @@ constexpr auto and_then_impl(Exp&& exp, F&& f) { } template >::value>* = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval()))> -constexpr auto and_then_impl(Exp&& exp, F&& f) { +constexpr auto and_then_impl(Exp &&exp, F &&f) { static_assert(detail::is_expected::value, "F must return an expected"); return exp.has_value() ? detail::invoke(std::forward(f)) @@ -3730,8 +3743,8 @@ struct TC; template (), *std::declval())), - detail::enable_if_t>::value>* = nullptr> -auto and_then_impl(Exp&& exp, F&& f) -> Ret { + detail::enable_if_t>::value> * = nullptr> +auto and_then_impl(Exp &&exp, F &&f) -> Ret { static_assert(detail::is_expected::value, "F must return an expected"); return exp.has_value() @@ -3741,8 +3754,8 @@ auto and_then_impl(Exp&& exp, F&& f) -> Ret { template ())), - detail::enable_if_t>::value>* = nullptr> -constexpr auto and_then_impl(Exp&& exp, F&& f) -> Ret { + detail::enable_if_t>::value> * = nullptr> +constexpr auto and_then_impl(Exp &&exp, F &&f) -> Ret { static_assert(detail::is_expected::value, "F must return an expected"); return exp.has_value() ? detail::invoke(std::forward(f)) @@ -3752,11 +3765,11 @@ constexpr auto and_then_impl(Exp&& exp, F&& f) -> Ret { #ifdef TL_EXPECTED_CXX14 template >::value>* = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval(), *std::declval())), - detail::enable_if_t::value>* = nullptr> -constexpr auto expected_map_impl(Exp&& exp, F&& f) { + detail::enable_if_t::value> * = nullptr> +constexpr auto expected_map_impl(Exp &&exp, F &&f) { using result = ret_t>; return exp.has_value() ? result(detail::invoke(std::forward(f), *std::forward(exp))) @@ -3764,11 +3777,11 @@ constexpr auto expected_map_impl(Exp&& exp, F&& f) { } template >::value>* = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval(), *std::declval())), - detail::enable_if_t::value>* = nullptr> -auto expected_map_impl(Exp&& exp, F&& f) { + detail::enable_if_t::value> * = nullptr> +auto expected_map_impl(Exp &&exp, F &&f) { using result = expected>; if (exp.has_value()) { detail::invoke(std::forward(f), *std::forward(exp)); @@ -3779,20 +3792,20 @@ auto expected_map_impl(Exp&& exp, F&& f) { } template >::value>* = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval())), - detail::enable_if_t::value>* = nullptr> -constexpr auto expected_map_impl(Exp&& exp, F&& f) { + detail::enable_if_t::value> * = nullptr> +constexpr auto expected_map_impl(Exp &&exp, F &&f) { using result = ret_t>; return exp.has_value() ? result(detail::invoke(std::forward(f))) : result(unexpect, std::forward(exp).error()); } template >::value>* = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval())), - detail::enable_if_t::value>* = nullptr> -auto expected_map_impl(Exp&& exp, F&& f) { + detail::enable_if_t::value> * = nullptr> +auto expected_map_impl(Exp &&exp, F &&f) { using result = expected>; if (exp.has_value()) { detail::invoke(std::forward(f)); @@ -3803,12 +3816,12 @@ auto expected_map_impl(Exp&& exp, F&& f) { } #else template >::value>* = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval(), *std::declval())), - detail::enable_if_t::value>* = nullptr> + detail::enable_if_t::value> * = nullptr> -constexpr auto expected_map_impl(Exp&& exp, F&& f) +constexpr auto expected_map_impl(Exp &&exp, F &&f) -> ret_t> { using result = ret_t>; @@ -3818,12 +3831,12 @@ constexpr auto expected_map_impl(Exp&& exp, F&& f) } template >::value>* = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval(), *std::declval())), - detail::enable_if_t::value>* = nullptr> + detail::enable_if_t::value> * = nullptr> -auto expected_map_impl(Exp&& exp, F&& f) -> expected> { +auto expected_map_impl(Exp &&exp, F &&f) -> expected> { if (exp.has_value()) { detail::invoke(std::forward(f), *std::forward(exp)); return {}; @@ -3833,11 +3846,11 @@ auto expected_map_impl(Exp&& exp, F&& f) -> expected> { } template >::value>* = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval())), - detail::enable_if_t::value>* = nullptr> + detail::enable_if_t::value> * = nullptr> -constexpr auto expected_map_impl(Exp&& exp, F&& f) +constexpr auto expected_map_impl(Exp &&exp, F &&f) -> ret_t> { using result = ret_t>; @@ -3846,11 +3859,11 @@ constexpr auto expected_map_impl(Exp&& exp, F&& f) } template >::value>* = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval())), - detail::enable_if_t::value>* = nullptr> + detail::enable_if_t::value> * = nullptr> -auto expected_map_impl(Exp&& exp, F&& f) -> expected> { +auto expected_map_impl(Exp &&exp, F &&f) -> expected> { if (exp.has_value()) { detail::invoke(std::forward(f)); return {}; @@ -3863,11 +3876,11 @@ auto expected_map_impl(Exp&& exp, F&& f) -> expected> { #if defined(TL_EXPECTED_CXX14) && !defined(TL_EXPECTED_GCC49) && \ !defined(TL_EXPECTED_GCC54) && !defined(TL_EXPECTED_GCC55) template >::value>* = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval(), std::declval().error())), - detail::enable_if_t::value>* = nullptr> -constexpr auto map_error_impl(Exp&& exp, F&& f) { + detail::enable_if_t::value> * = nullptr> +constexpr auto map_error_impl(Exp &&exp, F &&f) { using result = expected, detail::decay_t>; return exp.has_value() ? result(*std::forward(exp)) @@ -3875,11 +3888,11 @@ constexpr auto map_error_impl(Exp&& exp, F&& f) { std::forward(exp).error())); } template >::value>* = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval(), std::declval().error())), - detail::enable_if_t::value>* = nullptr> -auto map_error_impl(Exp&& exp, F&& f) { + detail::enable_if_t::value> * = nullptr> +auto map_error_impl(Exp &&exp, F &&f) { using result = expected, monostate>; if (exp.has_value()) { return result(*std::forward(exp)); @@ -3889,11 +3902,11 @@ auto map_error_impl(Exp&& exp, F&& f) { return result(unexpect, monostate{}); } template >::value>* = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval(), std::declval().error())), - detail::enable_if_t::value>* = nullptr> -constexpr auto map_error_impl(Exp&& exp, F&& f) { + detail::enable_if_t::value> * = nullptr> +constexpr auto map_error_impl(Exp &&exp, F &&f) { using result = expected, detail::decay_t>; return exp.has_value() ? result() @@ -3901,11 +3914,11 @@ constexpr auto map_error_impl(Exp&& exp, F&& f) { std::forward(exp).error())); } template >::value>* = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval(), std::declval().error())), - detail::enable_if_t::value>* = nullptr> -auto map_error_impl(Exp&& exp, F&& f) { + detail::enable_if_t::value> * = nullptr> +auto map_error_impl(Exp &&exp, F &&f) { using result = expected, monostate>; if (exp.has_value()) { return result(); @@ -3916,11 +3929,11 @@ auto map_error_impl(Exp&& exp, F&& f) { } #else template >::value>* = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval(), std::declval().error())), - detail::enable_if_t::value>* = nullptr> -constexpr auto map_error_impl(Exp&& exp, F&& f) + detail::enable_if_t::value> * = nullptr> +constexpr auto map_error_impl(Exp &&exp, F &&f) -> expected, detail::decay_t> { using result = expected, detail::decay_t>; @@ -3931,11 +3944,11 @@ constexpr auto map_error_impl(Exp&& exp, F&& f) } template >::value>* = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval(), std::declval().error())), - detail::enable_if_t::value>* = nullptr> -auto map_error_impl(Exp&& exp, F&& f) -> expected, monostate> { + detail::enable_if_t::value> * = nullptr> +auto map_error_impl(Exp &&exp, F &&f) -> expected, monostate> { using result = expected, monostate>; if (exp.has_value()) { return result(*std::forward(exp)); @@ -3946,11 +3959,11 @@ auto map_error_impl(Exp&& exp, F&& f) -> expected, monostate> { } template >::value>* = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval(), std::declval().error())), - detail::enable_if_t::value>* = nullptr> -constexpr auto map_error_impl(Exp&& exp, F&& f) + detail::enable_if_t::value> * = nullptr> +constexpr auto map_error_impl(Exp &&exp, F &&f) -> expected, detail::decay_t> { using result = expected, detail::decay_t>; @@ -3961,11 +3974,11 @@ constexpr auto map_error_impl(Exp&& exp, F&& f) } template >::value>* = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval(), std::declval().error())), - detail::enable_if_t::value>* = nullptr> -auto map_error_impl(Exp&& exp, F&& f) -> expected, monostate> { + detail::enable_if_t::value> * = nullptr> +auto map_error_impl(Exp &&exp, F &&f) -> expected, monostate> { using result = expected, monostate>; if (exp.has_value()) { return result(); @@ -3980,8 +3993,8 @@ auto map_error_impl(Exp&& exp, F&& f) -> expected, monostate> { template (), std::declval().error())), - detail::enable_if_t::value>* = nullptr> -constexpr auto or_else_impl(Exp&& exp, F&& f) { + detail::enable_if_t::value> * = nullptr> +constexpr auto or_else_impl(Exp &&exp, F &&f) { static_assert(detail::is_expected::value, "F must return an expected"); return exp.has_value() ? std::forward(exp) : detail::invoke(std::forward(f), @@ -3991,8 +4004,8 @@ constexpr auto or_else_impl(Exp&& exp, F&& f) { template (), std::declval().error())), - detail::enable_if_t::value>* = nullptr> -detail::decay_t or_else_impl(Exp&& exp, F&& f) { + detail::enable_if_t::value> * = nullptr> +detail::decay_t or_else_impl(Exp &&exp, F &&f) { return exp.has_value() ? std::forward(exp) : (detail::invoke(std::forward(f), std::forward(exp).error()), @@ -4002,8 +4015,8 @@ detail::decay_t or_else_impl(Exp&& exp, F&& f) { template (), std::declval().error())), - detail::enable_if_t::value>* = nullptr> -auto or_else_impl(Exp&& exp, F&& f) -> Ret { + detail::enable_if_t::value> * = nullptr> +auto or_else_impl(Exp &&exp, F &&f) -> Ret { static_assert(detail::is_expected::value, "F must return an expected"); return exp.has_value() ? std::forward(exp) : detail::invoke(std::forward(f), @@ -4013,8 +4026,8 @@ auto or_else_impl(Exp&& exp, F&& f) -> Ret { template (), std::declval().error())), - detail::enable_if_t::value>* = nullptr> -detail::decay_t or_else_impl(Exp&& exp, F&& f) { + detail::enable_if_t::value> * = nullptr> +detail::decay_t or_else_impl(Exp &&exp, F &&f) { return exp.has_value() ? std::forward(exp) : (detail::invoke(std::forward(f), std::forward(exp).error()), @@ -4024,65 +4037,65 @@ detail::decay_t or_else_impl(Exp&& exp, F&& f) { } // namespace detail template -constexpr bool operator==(const expected& lhs, - const expected& rhs) { +constexpr bool operator==(const expected &lhs, + const expected &rhs) { return (lhs.has_value() != rhs.has_value()) ? false : (!lhs.has_value() ? lhs.error() == rhs.error() : *lhs == *rhs); } template -constexpr bool operator!=(const expected& lhs, - const expected& rhs) { +constexpr bool operator!=(const expected &lhs, + const expected &rhs) { return (lhs.has_value() != rhs.has_value()) ? true : (!lhs.has_value() ? lhs.error() != rhs.error() : *lhs != *rhs); } template -constexpr bool operator==(const expected& lhs, - const expected& rhs) { +constexpr bool operator==(const expected &lhs, + const expected &rhs) { return (lhs.has_value() != rhs.has_value()) ? false : (!lhs.has_value() ? lhs.error() == rhs.error() : true); } template -constexpr bool operator!=(const expected& lhs, - const expected& rhs) { +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); } template -constexpr bool operator==(const expected& x, const U& v) { +constexpr bool operator==(const expected &x, const U &v) { return x.has_value() ? *x == v : false; } template -constexpr bool operator==(const U& v, const expected& x) { +constexpr bool operator==(const U &v, const expected &x) { return x.has_value() ? *x == v : false; } template -constexpr bool operator!=(const expected& x, const U& v) { +constexpr bool operator!=(const expected &x, const U &v) { return x.has_value() ? *x != v : true; } template -constexpr bool operator!=(const U& v, const expected& x) { +constexpr bool operator!=(const U &v, const expected &x) { return x.has_value() ? *x != v : true; } template -constexpr bool operator==(const expected& x, const unexpected& e) { +constexpr bool operator==(const expected &x, const unexpected &e) { return x.has_value() ? false : x.error() == e.value(); } template -constexpr bool operator==(const unexpected& e, const expected& x) { +constexpr bool operator==(const unexpected &e, const expected &x) { return x.has_value() ? false : x.error() == e.value(); } template -constexpr bool operator!=(const expected& x, const unexpected& e) { +constexpr bool operator!=(const expected &x, const unexpected &e) { return x.has_value() ? true : x.error() != e.value(); } template -constexpr bool operator!=(const unexpected& e, const expected& x) { +constexpr bool operator!=(const unexpected &e, const expected &x) { return x.has_value() ? true : x.error() != e.value(); } @@ -4091,9 +4104,9 @@ template ::value) && detail::is_swappable::value && std::is_move_constructible::value && - detail::is_swappable::value>* = nullptr> -void swap(expected& lhs, - expected& rhs) noexcept(noexcept(lhs.swap(rhs))) { + detail::is_swappable::value> * = nullptr> +void swap(expected &lhs, + expected &rhs) noexcept(noexcept(lhs.swap(rhs))) { lhs.swap(rhs); } } // namespace tl @@ -4124,24 +4137,25 @@ concept regex_concept = requires(T t, std::string_view pattern, typename T::regex_type; // Function to create a regex instance - { T::create_instance(pattern, ignore_case) } - ->std::same_as>; + { + T::create_instance(pattern, ignore_case) + } -> std::same_as>; // Function to perform regex search - { T::regex_search(input, std::declval()) } - ->std::same_as>>>; + { + T::regex_search(input, std::declval()) + } -> std::same_as>>>; // Function to match regex pattern - { T::regex_match(input, std::declval()) } - ->std::same_as; + { + T::regex_match(input, std::declval()) + } -> std::same_as; // Copy constructor - { T(std::declval()) } - ->std::same_as; + { T(std::declval()) } -> std::same_as; // Move constructor - { T(std::declval()) } - ->std::same_as; + { T(std::declval()) } -> std::same_as; }; #ifdef ADA_USE_UNSAFE_STD_REGEX_PROVIDER @@ -4184,9 +4198,9 @@ enum class errors : uint8_t { type_error }; #endif // ADA_ERRORS_H /* end file include/ada/errors.h */ -#include -#include #include +#include +#include #if ADA_TESTING #include @@ -4199,8 +4213,7 @@ namespace ada { // std::nullopt or a parameter with default value) template concept url_pattern_encoding_callback = requires(F f, std::string_view sv) { - { f(sv) } - ->std::same_as>; + { f(sv) } -> std::same_as>; }; // A structure providing matching patterns for individual components @@ -4374,9 +4387,9 @@ tl::expected, errors> parse_url_pattern_impl( #ifndef ADA_IMPLEMENTATION_H #define ADA_IMPLEMENTATION_H -#include #include #include +#include /* begin file include/ada/url.h */ /** @@ -4400,6 +4413,7 @@ tl::expected, errors> parse_url_pattern_impl( #ifndef ADA_CHECKERS_H #define ADA_CHECKERS_H + #include #include @@ -4530,10 +4544,10 @@ struct url_components { constexpr static uint32_t omitted = uint32_t(-1); url_components() = default; - url_components(const url_components& u) = default; - url_components(url_components&& u) noexcept = default; - url_components& operator=(url_components&& u) noexcept = default; - url_components& operator=(const url_components& u) = default; + url_components(const url_components &u) = default; + url_components(url_components &&u) noexcept = default; + url_components &operator=(url_components &&u) noexcept = default; + url_components &operator=(const url_components &u) = default; ~url_components() = default; /* @@ -4612,10 +4626,10 @@ struct url_aggregator; */ struct url : url_base { url() = default; - url(const url& u) = default; - url(url&& u) noexcept = default; - url& operator=(url&& u) noexcept = default; - url& operator=(const url& u) = default; + url(const url &u) = default; + url(url &&u) noexcept = default; + url &operator=(url &&u) noexcept = default; + url &operator=(const url &u) = default; ~url() override = default; /** @@ -4746,7 +4760,7 @@ struct url : url_base { * @return a constant reference to the underlying string. * @see https://url.spec.whatwg.org/#dom-url-username */ - [[nodiscard]] const std::string& get_username() const noexcept; + [[nodiscard]] const std::string &get_username() const noexcept; /** * @return Returns true on successful operation. @@ -4812,7 +4826,7 @@ struct url : url_base { * @return a constant reference to the underlying string. * @see https://url.spec.whatwg.org/#dom-url-password */ - [[nodiscard]] const std::string& get_password() const noexcept; + [[nodiscard]] const std::string &get_password() const noexcept; /** * Return this's URL's port, serialized. @@ -4864,22 +4878,22 @@ struct url : url_base { private: friend ada::url ada::parser::parse_url(std::string_view, - const ada::url*); + const ada::url *); friend ada::url_aggregator ada::parser::parse_url( - std::string_view, const ada::url_aggregator*); + std::string_view, const ada::url_aggregator *); friend void ada::helpers::strip_trailing_spaces_from_opaque_path( - ada::url& url) noexcept; + ada::url &url) noexcept; friend ada::url ada::parser::parse_url_impl(std::string_view, - const ada::url*); + const ada::url *); friend ada::url_aggregator ada::parser::parse_url_impl< - ada::url_aggregator, true>(std::string_view, const ada::url_aggregator*); + ada::url_aggregator, true>(std::string_view, const ada::url_aggregator *); inline void update_unencoded_base_hash(std::string_view input); inline void update_base_hostname(std::string_view input); inline void update_base_search(std::string_view input, const uint8_t query_percent_encode_set[]); - inline void update_base_search(std::optional&& input); + inline void update_base_search(std::optional &&input); inline void update_base_pathname(std::string_view input); inline void update_base_username(std::string_view input); inline void update_base_password(std::string_view input); @@ -4969,23 +4983,23 @@ struct url : url_base { * scheme string, be lower-cased, not contain spaces or tabs. It should * have no spurious trailing or leading content. */ - inline void set_scheme(std::string&& new_scheme) noexcept; + inline void set_scheme(std::string &&new_scheme) noexcept; /** * Take the scheme from another URL. The scheme string is moved from the * provided url. */ - constexpr void copy_scheme(ada::url&& u) noexcept; + constexpr void copy_scheme(ada::url &&u) noexcept; /** * Take the scheme from another URL. The scheme string is copied from the * provided url. */ - constexpr void copy_scheme(const ada::url& u); + constexpr void copy_scheme(const ada::url &u); }; // struct url -inline std::ostream& operator<<(std::ostream& out, const ada::url& u); +inline std::ostream &operator<<(std::ostream &out, const ada::url &u); } // namespace ada #endif // ADA_URL_H @@ -5405,6 +5419,7 @@ class url_pattern { #ifndef ADA_URL_PATTERN_HELPERS_H #define ADA_URL_PATTERN_HELPERS_H + #include #include #include @@ -6015,6 +6030,7 @@ tl::expected, errors> parse_url_pattern_impl( #ifndef ADA_SCHEME_INL_H #define ADA_SCHEME_INL_H + namespace ada::scheme { /** @@ -6102,6 +6118,7 @@ constexpr ada::scheme::type get_scheme_type(std::string_view scheme) noexcept { #ifndef ADA_SERIALIZERS_H #define ADA_SERIALIZERS_H + #include #include @@ -6146,6 +6163,7 @@ std::string ipv4(uint64_t address) noexcept; #ifndef ADA_STATE_H #define ADA_STATE_H + #include namespace ada { @@ -6272,9 +6290,10 @@ ada_warn_unused std::string to_string(ada::state s); #ifndef ADA_UNICODE_H #define ADA_UNICODE_H -#include + #include #include +#include /** * Unicode operations. These functions are not part of our public API and may @@ -6512,6 +6531,7 @@ constexpr bool to_lower_ascii(char* input, size_t length) noexcept; #ifndef ADA_URL_BASE_INL_H #define ADA_URL_BASE_INL_H + #include #if ADA_REGULAR_VISUAL_STUDIO #include @@ -6545,6 +6565,7 @@ url_base::scheme_default_port() const noexcept { #ifndef ADA_URL_INL_H #define ADA_URL_INL_H + #include #include #include @@ -6572,7 +6593,7 @@ namespace ada { [[nodiscard]] inline bool url::has_hostname() const noexcept { return host.has_value(); } -inline std::ostream& operator<<(std::ostream& out, const ada::url& u) { +inline std::ostream &operator<<(std::ostream &out, const ada::url &u) { return out << u.to_string(); } @@ -6669,7 +6690,7 @@ inline void url::update_base_search(std::string_view input, query = ada::unicode::percent_encode(input, query_percent_encode_set); } -inline void url::update_base_search(std::optional&& input) { +inline void url::update_base_search(std::optional &&input) { query = std::move(input); } @@ -6703,7 +6724,7 @@ constexpr void url::clear_search() { query = std::nullopt; } constexpr void url::set_protocol_as_file() { type = ada::scheme::type::FILE; } -inline void url::set_scheme(std::string&& new_scheme) noexcept { +inline void url::set_scheme(std::string &&new_scheme) noexcept { type = ada::scheme::get_scheme_type(new_scheme); // We only move the 'scheme' if it is non-special. if (!is_special()) { @@ -6711,12 +6732,12 @@ inline void url::set_scheme(std::string&& new_scheme) noexcept { } } -constexpr void url::copy_scheme(ada::url&& u) noexcept { +constexpr void url::copy_scheme(ada::url &&u) noexcept { non_special_scheme = u.non_special_scheme; type = u.type; } -constexpr void url::copy_scheme(const ada::url& u) { +constexpr void url::copy_scheme(const ada::url &u) { non_special_scheme = u.non_special_scheme; type = u.type; } @@ -6800,6 +6821,7 @@ ada_really_inline size_t url::parse_port(std::string_view view, #ifndef ADA_URL_COMPONENTS_INL_H #define ADA_URL_COMPONENTS_INL_H + namespace ada { [[nodiscard]] constexpr bool url_components::check_offset_consistency() @@ -6889,6 +6911,7 @@ namespace ada { #include #include + namespace ada { namespace parser {} @@ -6903,10 +6926,10 @@ namespace parser {} */ struct url_aggregator : url_base { url_aggregator() = default; - url_aggregator(const url_aggregator& u) = default; - url_aggregator(url_aggregator&& u) noexcept = default; - url_aggregator& operator=(url_aggregator&& u) noexcept = default; - url_aggregator& operator=(const url_aggregator& u) = default; + url_aggregator(const url_aggregator &u) = default; + url_aggregator(url_aggregator &&u) noexcept = default; + url_aggregator &operator=(url_aggregator &&u) noexcept = default; + url_aggregator &operator=(const url_aggregator &u) = default; ~url_aggregator() override = default; bool set_href(std::string_view input); @@ -7047,7 +7070,7 @@ struct url_aggregator : url_base { * @see * https://github.com/servo/rust-url/blob/b65a45515c10713f6d212e6726719a020203cc98/url/src/quirks.rs#L31 */ - [[nodiscard]] ada_really_inline const url_components& get_components() + [[nodiscard]] ada_really_inline const url_components &get_components() const noexcept; /** * Returns a string representation of this URL. @@ -7089,21 +7112,21 @@ struct url_aggregator : url_base { private: // helper methods friend void helpers::strip_trailing_spaces_from_opaque_path( - url_aggregator& url) noexcept; + url_aggregator &url) noexcept; // parse_url methods friend url_aggregator parser::parse_url( - std::string_view, const url_aggregator*); + std::string_view, const url_aggregator *); friend url_aggregator parser::parse_url_impl( - std::string_view, const url_aggregator*); + std::string_view, const url_aggregator *); friend url_aggregator parser::parse_url_impl( - std::string_view, const url_aggregator*); + std::string_view, const url_aggregator *); // url_pattern methods template friend tl::expected, errors> parse_url_pattern_impl(std::variant input, - const std::string_view* base_url, - const url_pattern_options* options); + const std::string_view *base_url, + const url_pattern_options *options); std::string buffer{}; url_components components{}; @@ -7164,12 +7187,12 @@ struct url_aggregator : url_base { ada_really_inline bool parse_host(std::string_view input); inline void update_base_authority(std::string_view base_buffer, - const url_components& base); + const url_components &base); inline void update_unencoded_base_hash(std::string_view input); inline void update_base_hostname(std::string_view input); inline void update_base_search(std::string_view input); inline void update_base_search(std::string_view input, - const uint8_t* query_percent_encode_set); + const uint8_t *query_percent_encode_set); inline void update_base_pathname(std::string_view input); inline void update_base_username(std::string_view input); inline void append_base_username(std::string_view input); @@ -7198,13 +7221,13 @@ struct url_aggregator : url_base { */ inline void set_scheme_from_view_with_colon( std::string_view new_scheme_with_colon) noexcept; - inline void copy_scheme(const url_aggregator& u) noexcept; + inline void copy_scheme(const url_aggregator &u) noexcept; inline void update_host_to_base_host(const std::string_view input) noexcept; }; // url_aggregator -inline std::ostream& operator<<(std::ostream& out, const url& u); +inline std::ostream &operator<<(std::ostream &out, const url &u); } // namespace ada #endif @@ -7275,7 +7298,7 @@ ada_really_inline size_t percent_encode_index(const std::string_view input, namespace ada { inline void url_aggregator::update_base_authority( - std::string_view base_buffer, const ada::url_components& base) { + std::string_view base_buffer, const ada::url_components &base) { std::string_view input = base_buffer.substr( base.protocol_end, base.host_start - base.protocol_end); ada_log("url_aggregator::update_base_authority ", input); @@ -7977,7 +8000,7 @@ constexpr bool url_aggregator::cannot_have_credentials_or_port() const { components.host_start == components.host_end; } -[[nodiscard]] ada_really_inline const ada::url_components& +[[nodiscard]] ada_really_inline const ada::url_components & url_aggregator::get_components() const noexcept { return components; } @@ -8355,8 +8378,8 @@ constexpr void url_aggregator::set_protocol_as_file() { return helpers::substring(buffer, components.pathname_start, ending_index); } -inline std::ostream& operator<<(std::ostream& out, - const ada::url_aggregator& u) { +inline std::ostream &operator<<(std::ostream &out, + const ada::url_aggregator &u) { return out << u.to_string(); } @@ -8436,10 +8459,10 @@ struct url_search_params { initialize(input); } - url_search_params(const url_search_params& u) = default; - url_search_params(url_search_params&& u) noexcept = default; - url_search_params& operator=(url_search_params&& u) noexcept = default; - url_search_params& operator=(const url_search_params& u) = default; + url_search_params(const url_search_params &u) = default; + url_search_params(url_search_params &&u) noexcept = default; + url_search_params &operator=(url_search_params &&u) noexcept = default; + url_search_params &operator=(const url_search_params &u) = default; ~url_search_params() = default; [[nodiscard]] inline size_t size() const noexcept; @@ -8555,11 +8578,11 @@ struct url_search_params { template struct url_search_params_iter { inline url_search_params_iter() : params(EMPTY) {} - url_search_params_iter(const url_search_params_iter& u) = default; - url_search_params_iter(url_search_params_iter&& u) noexcept = default; - url_search_params_iter& operator=(url_search_params_iter&& u) noexcept = + url_search_params_iter(const url_search_params_iter &u) = default; + url_search_params_iter(url_search_params_iter &&u) noexcept = default; + url_search_params_iter &operator=(url_search_params_iter &&u) noexcept = default; - url_search_params_iter& operator=(const url_search_params_iter& u) = default; + url_search_params_iter &operator=(const url_search_params_iter &u) = default; ~url_search_params_iter() = default; /** @@ -8571,9 +8594,9 @@ struct url_search_params_iter { private: static url_search_params EMPTY; - inline url_search_params_iter(url_search_params& params_) : params(params_) {} + inline url_search_params_iter(url_search_params ¶ms_) : params(params_) {} - url_search_params& params; + url_search_params ¶ms; size_t pos = 0; friend struct url_search_params; @@ -8590,6 +8613,7 @@ struct url_search_params_iter { #ifndef ADA_URL_SEARCH_PARAMS_INL_H #define ADA_URL_SEARCH_PARAMS_INL_H + #include #include #include @@ -8658,7 +8682,7 @@ inline size_t url_search_params::size() const noexcept { return params.size(); } inline std::optional url_search_params::get( const std::string_view key) { auto entry = std::ranges::find_if( - params, [&key](const auto& param) { return param.first == key; }); + params, [&key](const auto ¶m) { return param.first == key; }); if (entry == params.end()) { return std::nullopt; @@ -8671,7 +8695,7 @@ inline std::vector url_search_params::get_all( const std::string_view key) { std::vector out{}; - for (auto& param : params) { + for (auto ¶m : params) { if (param.first == key) { out.emplace_back(param.second); } @@ -8682,13 +8706,13 @@ inline std::vector url_search_params::get_all( inline bool url_search_params::has(const std::string_view key) noexcept { auto entry = std::ranges::find_if( - params, [&key](const auto& param) { return param.first == key; }); + params, [&key](const auto ¶m) { return param.first == key; }); return entry != params.end(); } inline bool url_search_params::has(std::string_view key, std::string_view value) noexcept { - auto entry = std::ranges::find_if(params, [&key, &value](const auto& param) { + auto entry = std::ranges::find_if(params, [&key, &value](const auto ¶m) { return param.first == key && param.second == value; }); return entry != params.end(); @@ -8717,7 +8741,7 @@ inline std::string url_search_params::to_string() const { inline void url_search_params::set(const std::string_view key, const std::string_view value) { - const auto find = [&key](const auto& param) { return param.first == key; }; + const auto find = [&key](const auto ¶m) { return param.first == key; }; auto it = std::ranges::find_if(params, find); @@ -8732,20 +8756,20 @@ inline void url_search_params::set(const std::string_view key, inline void url_search_params::remove(const std::string_view key) { std::erase_if(params, - [&key](const auto& param) { return param.first == key; }); + [&key](const auto ¶m) { return param.first == key; }); } inline void url_search_params::remove(const std::string_view key, const std::string_view value) { - std::erase_if(params, [&key, &value](const auto& param) { + std::erase_if(params, [&key, &value](const auto ¶m) { return param.first == key && param.second == value; }); } inline void url_search_params::sort() { // We rely on the fact that the content is valid UTF-8. - std::ranges::stable_sort(params, [](const key_value_pair& lhs, - const key_value_pair& rhs) { + std::ranges::stable_sort(params, [](const key_value_pair &lhs, + const key_value_pair &rhs) { size_t i = 0, j = 0; uint32_t low_surrogate1 = 0, low_surrogate2 = 0; while ((i < lhs.first.size() || low_surrogate1 != 0) && @@ -8879,6 +8903,7 @@ url_search_params_entries_iter::next() { #ifndef ADA_URL_PATTERN_INL_H #define ADA_URL_PATTERN_INL_H + #include #include #include @@ -9202,25 +9227,24 @@ result> url_pattern::match( // https://github.com/cloudflare/workerd/blob/8620d14012513a6ce04d079e401d3becac3c67bd/src/workerd/jsg/url.c%2B%2B#L2038 protocol = url->get_protocol().substr(0, url->get_protocol().size() - 1); // Set username to url’s username. - username = std::move(url->get_username()); + username = url->get_username(); // Set password to url’s password. - password = std::move(url->get_password()); + password = url->get_password(); // Set hostname to url’s host, serialized, or the empty string if the value // is null. - hostname = std::move(url->get_hostname()); + hostname = url->get_hostname(); // Set port to url’s port, serialized, or the empty string if the value is // null. - port = std::move(url->get_port()); + port = url->get_port(); // Set pathname to the result of URL path serializing url. - pathname = std::move(url->get_pathname()); + pathname = url->get_pathname(); // Set search to url’s query or the empty string if the value is null. // IMPORTANT: Not documented on the URLPattern spec, but search prefix '?' // is removed. Similar work was done on workerd: // https://github.com/cloudflare/workerd/blob/8620d14012513a6ce04d079e401d3becac3c67bd/src/workerd/jsg/url.c%2B%2B#L2232 if (url->has_search()) { auto view = url->get_search(); - search = - view.starts_with("?") ? url->get_search().substr(1) : std::move(view); + search = view.starts_with("?") ? url->get_search().substr(1) : view; } // Set hash to url’s fragment or the empty string if the value is null. // IMPORTANT: Not documented on the URLPattern spec, but hash prefix '#' is @@ -9228,8 +9252,7 @@ result> url_pattern::match( // https://github.com/cloudflare/workerd/blob/8620d14012513a6ce04d079e401d3becac3c67bd/src/workerd/jsg/url.c%2B%2B#L2242 if (url->has_hash()) { auto view = url->get_hash(); - hash = - view.starts_with("#") ? url->get_hash().substr(1) : std::move(view); + hash = view.starts_with("#") ? url->get_hash().substr(1) : view; } } @@ -9367,6 +9390,7 @@ result> url_pattern::match( #include #include + namespace ada::url_pattern_helpers { #ifdef ADA_TESTING inline std::string to_string(token_type type) { @@ -9456,7 +9480,8 @@ constructor_string_parser::is_non_special_pattern_char( // If token’s value is not value, then return false. // TODO: Remove this once we make sure get_safe_token returns a non-empty // string. - if (!token->value.empty() && token->value[0] != value) { + if (!token->value.empty() && + static_cast(token->value[0]) != value) { return false; } @@ -9476,8 +9501,8 @@ constructor_string_parser::get_safe_token(size_t index) const { // If index is less than parser’s token list's size, then return parser’s // token list[index]. if (index < token_list.size()) [[likely]] { - return &token_list[index]; - } + return &token_list[index]; + } // Assert: parser’s token list's size is greater than or equal to 1. ADA_ASSERT_TRUE(!token_list.empty()); @@ -10454,14 +10479,14 @@ constructor_string_parser::parse(std::string_view input) { #ifndef ADA_ADA_VERSION_H #define ADA_ADA_VERSION_H -#define ADA_VERSION "3.1.1" +#define ADA_VERSION "3.1.3" namespace ada { enum { ADA_VERSION_MAJOR = 3, ADA_VERSION_MINOR = 1, - ADA_VERSION_REVISION = 1, + ADA_VERSION_REVISION = 3, }; } // namespace ada @@ -10475,8 +10500,9 @@ enum { #ifndef ADA_IMPLEMENTATION_INL_H #define ADA_IMPLEMENTATION_INL_H -#include + #include +#include namespace ada {