From 95f2a76c90d0b0bd660504fd16dd0c2df09442c6 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 18 Dec 2021 07:43:33 +0200 Subject: [PATCH] Specialize std::basic_common_reference to enable std::common_reference and std::common_reference_with --- include/boost/core/detail/string_view.hpp | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/include/boost/core/detail/string_view.hpp b/include/boost/core/detail/string_view.hpp index fedfbc9..c8343c8 100644 --- a/include/boost/core/detail/string_view.hpp +++ b/include/boost/core/detail/string_view.hpp @@ -31,6 +31,10 @@ #if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW) # include #endif +#if BOOST_CXX_VERSION >= 202000L +# include +# include +#endif namespace boost { @@ -1216,4 +1220,29 @@ typedef basic_string_view u8string_view; } // namespace core } // namespace boost +// std::common_reference support +// needed for iterators that have reference=string_view and value_type=std::string + +#if BOOST_CXX_VERSION >= 202000L && defined(__cpp_lib_concepts) && __cpp_lib_concepts >= 201907L + +template class Q1, template class Q2> +struct std::basic_common_reference< + boost::core::basic_string_view, + std::basic_string, A>, + Q1, Q2> +{ + using type = boost::core::basic_string_view; +}; + +template class Q1, template class Q2> +struct std::basic_common_reference< + std::basic_string, A>, + boost::core::basic_string_view, + Q1, Q2> +{ + using type = boost::core::basic_string_view; +}; + +#endif + #endif // #ifndef BOOST_CORE_STRING_VIEW_HPP_INCLUDED