|
25 | 25 | #include <array> // for array |
26 | 26 | #include <cstddef> // for ptrdiff_t, size_t, nullptr_t |
27 | 27 | #include <iterator> // for reverse_iterator, distance, random_access_... |
| 28 | +#include <memory> // for pointer_traits |
28 | 29 | #include <type_traits> // for enable_if_t, declval, is_convertible, inte... |
29 | 30 |
|
| 31 | +#if defined(__has_include) && __has_include(<version>) |
| 32 | +#include <version> |
| 33 | +#endif |
| 34 | + |
30 | 35 | #if defined(_MSC_VER) && !defined(__clang__) |
31 | 36 | #pragma warning(push) |
32 | 37 |
|
@@ -110,6 +115,9 @@ namespace details |
110 | 115 | class span_iterator |
111 | 116 | { |
112 | 117 | public: |
| 118 | +#if defined(__cpp_lib_ranges) || (defined(_MSVC_STL_VERSION) && defined(__cpp_lib_concepts)) |
| 119 | + using iterator_concept = std::contiguous_iterator_tag; |
| 120 | +#endif // __cpp_lib_ranges |
113 | 121 | using iterator_category = std::random_access_iterator_tag; |
114 | 122 | using value_type = std::remove_cv_t<Type>; |
115 | 123 | using difference_type = std::ptrdiff_t; |
@@ -329,8 +337,24 @@ namespace details |
329 | 337 | pointer begin_ = nullptr; |
330 | 338 | pointer end_ = nullptr; |
331 | 339 | pointer current_ = nullptr; |
| 340 | + |
| 341 | + template <typename Ptr> |
| 342 | + friend struct std::pointer_traits; |
332 | 343 | }; |
| 344 | +}} // namespace gsl::details |
| 345 | + |
| 346 | +template <class Type> |
| 347 | +struct std::pointer_traits<::gsl::details::span_iterator<Type>> { |
| 348 | + using pointer = ::gsl::details::span_iterator<Type>; |
| 349 | + using element_type = Type; |
| 350 | + using difference_type = ptrdiff_t; |
| 351 | + |
| 352 | + static constexpr element_type* to_address(const pointer i) noexcept { |
| 353 | + return i.current_; |
| 354 | + } |
| 355 | +}; |
333 | 356 |
|
| 357 | +namespace gsl { namespace details { |
334 | 358 | template <std::size_t Ext> |
335 | 359 | class extent_type |
336 | 360 | { |
|
0 commit comments