Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix Range under libc++ >= 19 where basic_string_view only allows char…
… types Summary: LLVM 19 removed the base templates for `std::char_traits` and only allows the following types to be used `char`, `wchar_t`, `char8_t`, `char16_t`, `char32_t`. From the [release notes](https://github.com/llvm/llvm-project/blob/release/19.x/libcxx/docs/ReleaseNotes/19.rst): > The base template for `std::char_traits` has been removed in LLVM 19. If you are using `std::char_traits` with types other than `char`, `wchar_t`, `char8_t`, `char16_t`, `char32_t` or a custom character type for which you specialized `std::char_traits`, your code will stop working. The Standard does not mandate that a base template is provided, and such a base template is bound to be incorrect for some types, which could currently cause unexpected behavior while going undetected. Fixes the following eror: ``` llvm-project/libcxx/include/string_view:300:42: error: implicit instantiation of undefined template 'std::char_traits<unsigned char>' 300 | static_assert(is_same<_CharT, typename traits_type::char_type>::value, | ^ llvm-project/libcxx/include/__type_traits/is_constructible.h:24:79: note: in instantiation of template class 'std::basic_string_view<unsigned char>' requested here 24 | struct _LIBCPP_TEMPLATE_VIS is_constructible : public integral_constant<bool, __is_constructible(_Tp, _Args...)> {}; | ^ folly/Traits.h:694:24: note: in instantiation of template class 'std::is_constructible<std::basic_string_view<unsigned char>, const unsigned char *const &, unsigned long>' requested here 694 | : std::conditional<T::value, Conjunction<TList...>, T>::type {}; | ^ folly/Range.h:647:9: note: in instantiation of template class 'folly::Conjunction<std::is_constructible<std::basic_string_view<unsigned char>, const unsigned char *const &, unsigned long>, std::is_constructible<folly::Range<const char *>, std::basic_string_view<unsigned char>>>' requested here 647 | : Conjunction< | ^ folly/Range.h:666:16: note: in instantiation of template class 'folly::Range<const unsigned char *>::IsConstructibleViaStringView<folly::Range<const char *>>' requested here 666 | !IsConstructibleViaStringView<Tgt>::value, | ^ folly/Range.h:668:22: note: while substituting prior template arguments into non-type template parameter [with Tgt = folly::Range<const char *>] 668 | constexpr explicit operator Tgt() const noexcept( | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 669 | std::is_nothrow_constructible<Tgt, Iter const&, size_type>::value) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 670 | return Tgt(b_, walk_size()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 671 | } | ~ folly/Range.h:1665:19: note: while substituting deduced template arguments into function template 'operator type-parameter-0-0' [with Tgt = folly::Range<const char *>, $1 = (no value)] 1665 | StringPiece(haystack), StringPiece(needles)); | ^ llvm-project/libcxx/include/__string/char_traits.h:45:8: note: template is declared here 45 | struct char_traits; | ^ ``` Reviewed By: thevinster Differential Revision: D62275652 fbshipit-source-id: fc4288c7113f7a76b96f21d4d3766d75bec11988
- Loading branch information