martinmoene/span-lite

extent_t is ptrdiff_t, which ruins SFINAE for people expecting std::size_t

ThePhD opened this issue · 6 comments

I wrote a template

template <typename T, std::size_t Extent>
void process(span<T, Extent> ...) {

}

This didn't work properly, because extent_t in span-lite is ptrdiff_t. Can I change this to std::size_t and make a PR, or is there a specific reason span-lite made this choice?

Related to Review span in face of p1024 and p1089 (Continued from #14).

It's so due to span's history (see e.g. p0122r1).

Currently, cppreference says:

inline constexpr std::size_t dynamic_extent = std::numeric_limits<std::size_t>::max(); (since C++20)

and:

Since std::size_t is an unsigned type, an equivalent definition is:

inline constexpr std::size_t dynamic_extent = -1;

So it seems like a good idea to change extent_t to be std::size_t.

I'll try and update span lite in this respect.

I updated it for you. Let me know if anything is wrong. :D

Thanks @ThePhD,

In the end the changes you offered in PR #46 were handled in 54ae6ba, 9becd69 (extent) and in 0c95c29 (index_type -> size_type) and 17abefb (change default type to std::size_t).

Yaaay! 🎉

Thanks for doing this so quickly. It certainly covers all of my use cases. I appreciate it! ❤️

Hi, thank you for this project!
I would be grateful if we could see this change in a new release.

Released v0.7.0.