https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100044
Bug ID: 100044 Summary: ranges::subrange CTAD for __iterator_sentinel_pair not work Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: hewillk at gmail dot com Target Milestone: --- libstdc++ defines the CATD of __iterator_sentinel_pair for the subranges in ranges_util.h#L355: 355 template<__detail::__iterator_sentinel_pair _Pr> 356 subrange(_Pr) 357 -> subrange<tuple_element_t<0, _Pr>, tuple_element_t<1, _Pr>>; 358 359 template<__detail::__iterator_sentinel_pair _Pr> 360 subrange(_Pr, __detail::__make_unsigned_like_t<iter_difference_t< 361 tuple_element_t<0, _Pr>>>) 362 -> subrange<tuple_element_t<0, _Pr>, tuple_element_t<1, _Pr>, 363 subrange_kind::sized>; It should be for the convenience to create a subrange directly from the iterator and sentinel pair: #include <ranges> #include <vector> int main() { std::vector v1{1, 2, 3}; std::pair p{v1.begin(), v1.end()}; std::ranges::subrange sb{p}; } But this seems to not work, since subrange(_Rng&& __r) will constraint the _Rng at the beginning, which will cause us to be blocked early: <source>: In function 'int main()': <source>:7:29: error: no matching function for call to 'std::ranges::subrange<__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, std::ranges::subrange_kind::sized>::subrange(<brace-enclosed initializer list>)' 7 | std::ranges::subrange sb{p}; Should we consider it a library bug?