Created on 2023-10-27.00:00:00 last changed 13 months ago
Proposed resolution:
This wording is relative to N4964.
Modify [range.iota.view], class template iota_view synopsis, as indicated:
namespace std::ranges { […] template<weakly_incrementable W, semiregular Bound = unreachable_sentinel_t> requires weakly-equality-comparable-with<W, Bound> && copyable<W> class iota_view : public view_interface<iota_view<W, Bound>> { private: […] W value_ = W(); // exposition only Bound bound_ = Bound(); // exposition only public: […] constexpr iterator begin() const; constexpr auto end() const; constexpr iterator end() const requires same_as<W, Bound>; constexpr bool empty() const; constexpr auto size() const requires see below; }; […] }[…]
constexpr iterator end() const requires same_as<W, Bound>;-14- Effects: Equivalent to: return iterator{bound_};
constexpr bool empty() const;-?- Effects: Equivalent to: return value_ == bound_;
[…]
[ 2023-11-11 Approved at November 2023 meeting in Kona. Status changed: Voting → WP. ]
[ 2023-11-02; Reflector poll ]
Set status to Tentatively Ready after seven votes in favour during reflector poll.
When iota_view's template parameter is not an integer type and does not model advanceable, its size member will not be provided as constraints are not satisfied.
If the type further fails to model the incrementable, this results in its view_interface base being unable to synthesize a valid empty member as iota_view will just be an input_range (demo):
#include <ranges>
#include <vector>
#include <iostream>
int main() {
std::vector<int> v;
auto it = std::back_inserter(v);
auto s = std::ranges::subrange(it, std::unreachable_sentinel);
auto r = std::views::iota(it);
std::cout << s.empty() << "\n"; // 0
std::cout << r.empty() << "\n"; // ill-formed
}
This seems to be an oversight. I don't see a reason why iota_view doesn't provide empty as it does store the start and end like subrange, in which case it's easy to tell if it's empty just by comparing the two.
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-11-13 14:08:10 | admin | set | messages: + msg13855 |
2023-11-13 14:08:10 | admin | set | status: voting -> wp |
2023-11-07 21:41:54 | admin | set | status: ready -> voting |
2023-11-03 18:08:35 | admin | set | messages: + msg13815 |
2023-11-03 18:08:35 | admin | set | status: new -> ready |
2023-10-28 12:58:43 | admin | set | messages: + msg13773 |
2023-10-27 00:00:00 | admin | create |