@@ -386,8 +386,6 @@ template <>
386
386
struct type_caster <absl::CivilYear>
387
387
: public absl_civil_date_caster<absl::CivilYear> {};
388
388
389
- // Using internal namespace to avoid name collisons in case this code is
390
- // accepted upsteam (pybind11).
391
389
namespace internal {
392
390
393
391
template <typename T>
@@ -397,33 +395,6 @@ static constexpr bool is_buffer_interface_compatible_type =
397
395
std::is_same<T, std::complex<float >>::value ||
398
396
std::is_same<T, std::complex<double >>::value;
399
397
400
- template <typename T, typename SFINAE = void >
401
- struct format_descriptor_char1 : format_descriptor<T> {};
402
-
403
- template <typename T>
404
- struct format_descriptor_char1 <
405
- T,
406
- detail::enable_if_t <detail::is_same_ignoring_cvref<T, PyObject*>::value>> {
407
- static constexpr const char c = ' O' ;
408
- static constexpr const char value[2 ] = {c, ' \0 ' };
409
- static std::string format () { return std::string (1 , c); }
410
- };
411
-
412
- template <typename T, typename SFINAE = void >
413
- struct format_descriptor_char2 {
414
- static constexpr const char c = ' \0 ' ;
415
- };
416
-
417
- template <typename T>
418
- struct format_descriptor_char2 <std::complex<T>> : format_descriptor<T> {};
419
-
420
- template <typename T>
421
- inline bool buffer_view_matches_format_descriptor (const char * view_format) {
422
- return view_format[0 ] == format_descriptor_char1<T>::c ||
423
- (view_format[0 ] == ' Z' &&
424
- view_format[1 ] == format_descriptor_char2<T>::c);
425
- }
426
-
427
398
} // namespace internal
428
399
429
400
// Returns {true, a span referencing the data contained by src} without copying
@@ -438,7 +409,7 @@ std::tuple<bool, absl::Span<T>> LoadSpanFromBuffer(handle src) {
438
409
if (PyObject_GetBuffer (src.ptr (), &view, flags) == 0 ) {
439
410
auto cleanup = absl::MakeCleanup ([&view] { PyBuffer_Release (&view); });
440
411
if (view.ndim == 1 && view.strides [0 ] == sizeof (T) &&
441
- internal::buffer_view_matches_format_descriptor <T>(view. format )) {
412
+ buffer_info (&view, /* ownview= */ false ). item_type_is_equivalent_to <T>()) {
442
413
return {true , absl::MakeSpan (static_cast <T*>(view.buf ), view.shape [0 ])};
443
414
}
444
415
} else {
0 commit comments