martinmoene/span-lite

Support for iterator constructors/deduction guides

Ryan-rsm-McKenzie opened this issue · 9 comments

Is any support for this planned? See here and here for reference.

@Ryan-rsm-McKenzie Thanks for your question/suggestion. I wasn't aware yet of these deduction guides. I'll take a look, will not be immediately though.

span iterator deduction guide:

template<class It, class EndOrSize>
span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;

Constraints: It satisfies contiguous_­iterator.
std::iter_reference_t (C++20, p1037)
std::remove_reference_t (C++14/C++11)

The new deduction guides are failing to deduce reference types for iterators, presumably because of this line:

struct iter_reference { typedef T type; };

Here's a godbolt link.

Thanks @Ryan-rsm-McKenzie for your feedback. Currently my attention is a bit too scattered to do a good job in one go. A little back and forth may help :)

Having a look at it...

@Ryan-rsm-McKenzie I think this issue can be closed, otherwise please reopen it.

You're missing an iterator based constructor, so code like this won't compile.

I can't re-open the issue because you closed it

this works