@@ -84,6 +84,13 @@ template <class _CharT, class _Traits, class _Alloc>
8484inline constexpr bool __cccl_is_std_string_v<::std::basic_string<_CharT, _Traits, _Alloc>> = true;
8585#endif // !_CCCL_COMPILER(NVRTC)
8686
87+ template <class _Tp>
88+ inline constexpr bool __is_std_char_traits_v = false;
89+ #if !_CCCL_COMPILER(NVRTC)
90+ template <class _Tp>
91+ inline constexpr bool __is_std_char_traits_v<::std::char_traits<_Tp>> = true;
92+ #endif // !_CCCL_COMPILER(NVRTC)
93+
8794template <class _Tp>
8895inline constexpr bool __cccl_is_std_string_view_v = false;
8996#if __cpp_lib_string_view >= 201606L
@@ -134,6 +141,13 @@ _CCCL_CONCEPT __cccl_basic_sv_compatible_range = _CCCL_REQUIRES_EXPR((_Range, _C
134141 || __cccl_basic_sv_compatible_range_check_traits_std_ext<_Range, _CharT, _Traits>) )) //
135142 );
136143
144+ template <class _Traits, class _HostTraits>
145+ _CCCL_CONCEPT __cccl_basic_sv_is_std_to_cuda_std_char_traits = _CCCL_REQUIRES_EXPR((_Traits, _HostTraits)) //
146+ ( //
147+ requires(__is_cuda_std_char_traits_v<_Traits>), //
148+ requires(__is_std_char_traits_v<_HostTraits>) //
149+ );
150+
137151template <class _CharT, class _Traits>
138152class _CCCL_TYPE_VISIBILITY_DEFAULT basic_string_view
139153{
@@ -201,30 +215,32 @@ public:
201215 }
202216
203217#if !_CCCL_COMPILER(NVRTC)
204- _CCCL_TEMPLATE(class _Traits2 = _Traits, class _Alloc)
205- _CCCL_REQUIRES(is_same_v<_Traits2, char_traits<_CharT>>)
206- _CCCL_HOST_API constexpr basic_string_view(
207- const ::std::basic_string<_CharT, ::std::char_traits<_CharT>, _Alloc>& __sv) noexcept
218+ _CCCL_TEMPLATE(class _Traits2, class _Alloc)
219+ _CCCL_REQUIRES(__cccl_basic_sv_is_std_to_cuda_std_char_traits<_Traits, _Traits2>)
220+ _CCCL_HOST_API constexpr basic_string_view(const ::std::basic_string<_CharT, _Traits2, _Alloc>& __sv) noexcept
208221 : __data_{__sv.data()}
209222 , __size_{__sv.size()}
210223 {}
211224
212- template <class _Alloc>
213- _CCCL_HOST_API constexpr basic_string_view(const ::std::basic_string<_CharT, _Traits, _Alloc>& __sv) noexcept
225+ _CCCL_TEMPLATE(class _Traits2, class _Alloc)
226+ _CCCL_REQUIRES(is_same_v<_Traits, _Traits2>)
227+ _CCCL_HOST_API constexpr basic_string_view(const ::std::basic_string<_CharT, _Traits2, _Alloc>& __sv) noexcept
214228 : __data_{__sv.data()}
215229 , __size_{__sv.size()}
216230 {}
217231#endif // !_CCCL_COMPILER(NVRTC)
218232
219233#if __cpp_lib_string_view >= 201606L
220- _CCCL_TEMPLATE(class _Traits2 = _Traits )
221- _CCCL_REQUIRES(is_same_v<_Traits2, char_traits<_CharT> >)
222- _CCCL_HOST_API constexpr basic_string_view(::std::basic_string_view<_CharT> __s) noexcept
234+ _CCCL_TEMPLATE(class _Traits2)
235+ _CCCL_REQUIRES(__cccl_basic_sv_is_std_to_cuda_std_char_traits<_Traits, _Traits2 >)
236+ _CCCL_HOST_API constexpr basic_string_view(const ::std::basic_string_view<_CharT, _Traits2>& __s) noexcept
223237 : __data_{__s.data()}
224238 , __size_{__s.size()}
225239 {}
226240
227- _CCCL_HOST_API constexpr basic_string_view(::std::basic_string_view<_CharT, _Traits> __s) noexcept
241+ _CCCL_TEMPLATE(class _Traits2)
242+ _CCCL_REQUIRES(is_same_v<_Traits, _Traits2>)
243+ _CCCL_HOST_API constexpr basic_string_view(const ::std::basic_string_view<_CharT, _Traits2>& __s) noexcept
228244 : __data_{__s.data()}
229245 , __size_{__s.size()}
230246 {}
0 commit comments