Specialize std::basic_common_reference to enable std::common_reference and std::common_reference_with

This commit is contained in:
Peter Dimov
2021-12-18 07:43:33 +02:00
parent 28d26d13f1
commit 95f2a76c90

View File

@ -31,6 +31,10 @@
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
# include <string_view>
#endif
#if BOOST_CXX_VERSION >= 202000L
# include <type_traits>
# include <version>
#endif
namespace boost
{
@ -1216,4 +1220,29 @@ typedef basic_string_view<char8_t> 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 Ch, class A, template<class> class Q1, template<class> class Q2>
struct std::basic_common_reference<
boost::core::basic_string_view<Ch>,
std::basic_string<Ch, std::char_traits<Ch>, A>,
Q1, Q2>
{
using type = boost::core::basic_string_view<Ch>;
};
template<class Ch, class A, template<class> class Q1, template<class> class Q2>
struct std::basic_common_reference<
std::basic_string<Ch, std::char_traits<Ch>, A>,
boost::core::basic_string_view<Ch>,
Q1, Q2>
{
using type = boost::core::basic_string_view<Ch>;
};
#endif
#endif // #ifndef BOOST_CORE_STRING_VIEW_HPP_INCLUDED