From ba48ef3949b242f473b0213fd8edf90774a4aa56 Mon Sep 17 00:00:00 2001 From: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> Date: Wed, 16 Feb 2022 10:06:00 -0600 Subject: [PATCH] GCC Build fix. (#7659) GCC doesn't accept accessing member variables inside the noexcept expression of a member function. GCC also requires that template specializations for an inner template be outside of all classes. Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> --- .../AzCore/AzCore/std/ranges/ranges_adaptor.h | 12 ++-- .../AzCore/AzCore/std/string/string_view.h | 55 ++++++++++++------- 2 files changed, 40 insertions(+), 27 deletions(-) diff --git a/Code/Framework/AzCore/AzCore/std/ranges/ranges_adaptor.h b/Code/Framework/AzCore/AzCore/std/ranges/ranges_adaptor.h index 6c814def5d..10e8998584 100644 --- a/Code/Framework/AzCore/AzCore/std/ranges/ranges_adaptor.h +++ b/Code/Framework/AzCore/AzCore/std/ranges/ranges_adaptor.h @@ -23,28 +23,28 @@ namespace AZStd::ranges::views::Internal {} template constexpr decltype(auto) operator()(Args&&... args) & - noexcept(noexcept(AZStd::invoke(m_outer, AZStd::invoke(m_inner, AZStd::forward(args)...)))) + noexcept(noexcept(AZStd::invoke(declval(), AZStd::invoke(declval(), AZStd::forward(args)...)))) { return AZStd::invoke(m_outer, AZStd::invoke(m_inner, AZStd::forward(args)...)); } template constexpr decltype(auto) operator()(Args&&... args) const& - noexcept(noexcept(AZStd::invoke(m_outer, AZStd::invoke(m_inner, AZStd::forward(args)...)))) + noexcept(noexcept(AZStd::invoke(declval(), AZStd::invoke(declval(), AZStd::forward(args)...)))) { return AZStd::invoke(m_outer, AZStd::invoke(m_inner, AZStd::forward(args)...)); } // template constexpr decltype(auto) operator()(Args&&... args) && - noexcept(noexcept(AZStd::invoke(AZStd::move(m_outer), - AZStd::invoke(AZStd::move(m_inner), AZStd::forward(args)...)))) + noexcept(noexcept(AZStd::invoke(declval(), + AZStd::invoke(declval(), AZStd::forward(args)...)))) { return AZStd::invoke(AZStd::move(m_outer), AZStd::invoke(AZStd::move(m_inner), AZStd::forward(args)...)); } template constexpr decltype(auto) operator()(Args&&... args) const&& - noexcept(noexcept(AZStd::invoke(AZStd::move(m_outer), - AZStd::invoke(AZStd::move(m_inner), AZStd::forward(args)...)))) + noexcept(noexcept(AZStd::invoke(declval(), + AZStd::invoke(declval(), AZStd::forward(args)...)))) { return AZStd::invoke(AZStd::move(m_outer), AZStd::invoke(AZStd::move(m_inner), AZStd::forward(args)...)); } diff --git a/Code/Framework/AzCore/AzCore/std/string/string_view.h b/Code/Framework/AzCore/AzCore/std/string/string_view.h index af1482b05b..e9becea4b0 100644 --- a/Code/Framework/AzCore/AzCore/std/string/string_view.h +++ b/Code/Framework/AzCore/AzCore/std/string/string_view.h @@ -595,31 +595,44 @@ namespace AZStd static constexpr int_type not_eof(int_type c) noexcept { return c != eof() ? c : !eof(); } }; + // string_view forward declaation + template > + class basic_string_view; +} + +namespace AZStd::Internal +{ + template + struct has_operator_basic_string_view + : false_type + {}; + + template + struct has_operator_basic_string_view::operator basic_string_view)>> + : true_type + {}; + + // If the range has a traits_type element, it must match + template + static constexpr bool range_trait_type_matches = true; + template + inline constexpr bool range_trait_type_matches::traits_type>, + bool_constant::traits_type, Traits>> + >>> = false; +} +namespace AZStd +{ /** - * Immutable string wrapper based on boost::const_string and std::string_view. When we operate on + * Immutable string wrapper based on std::string_view. When we operate on * const char* we don't know if this points to NULL terminated string or just a char array. * to have a clear distinction between them we provide this wrapper. */ - template > + template class basic_string_view { - template - static constexpr bool has_operator_basic_string_view = false; - template - static constexpr bool has_operator_basic_string_view>().operator basic_string_view()) - >> = true; - - // If the range has a traits_type element, it must match - template - static constexpr bool range_trait_type_matches = true; - template - static constexpr bool range_trait_type_matches::traits_type>, - bool_constant::traits_type, Traits>> - >>> = false; - public: using traits_type = Traits; using value_type = Element; @@ -674,8 +687,8 @@ namespace AZStd bool_constant>, bool_constant>, bool_constant, value_type>>, - bool_constant>, - bool_constant> + negation>, + bool_constant> >>> constexpr basic_string_view(R&& r) : m_begin(ranges::data(r))