public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "hewillk at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/100631] ranges::elements_view:: _Sentinel is missing __distance_from() that can access _M_current of _Iterator
Date: Mon, 17 May 2021 04:50:14 +0000	[thread overview]
Message-ID: <bug-100631-4-uGi5yf6mEW@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-100631-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100631

--- Comment #2 from 康桓瑋 <hewillk at gmail dot com> ---
In addition, I think elements_view::_Sentinel::_M_equal should be a template
function, and elements_view::_Iterator also needs to declare _Sentinel<!_Const>
as a friend, otherwise the following valid codes will be rejected:

https://godbolt.org/z/7aa75vqsP


#include <ranges>

int main() {
  auto r = std::views::iota(0)
    | std::views::transform([](int) { return std::make_pair(42, "hello"); })
    | std::views::keys;

  auto b = std::ranges::cbegin(r);
  auto e = std::end(r);
  b.base() == e.base();

  b == e; // error
}


<source>:12:9:   required from here
/opt/compiler-explorer/gcc-trunk-20210513/include/c++/12.0.0/ranges:3675:34:
error: cannot convert 'const
std::ranges::elements_view<std::ranges::transform_view<std::ranges::iota_view<int,
std::unreachable_sentinel_t>, main()::<lambda(int)> >, 0>::_Iterator<true>' to
'const
std::ranges::elements_view<std::ranges::transform_view<std::ranges::iota_view<int,
std::unreachable_sentinel_t>, main()::<lambda(int)> >, 0>::_Iterator<false>&'
 3675 |             { return __y._M_equal(__x); }
      |                      ~~~~~~~~~~~~^~~~~
/opt/compiler-explorer/gcc-trunk-20210513/include/c++/12.0.0/ranges:3645:45:
note:   initializing argument 1 of 'constexpr bool
std::ranges::elements_view<_Vp, _Nm>::_Sentinel<_Const>::_M_equal(const
std::ranges::elements_view<_Vp, _Nm>::_Iterator<_Const>&) const [with bool
_Const = false; _Vp = std::ranges::transform_view<std::ranges::iota_view<int,
std::unreachable_sentinel_t>, main()::<lambda(int)> >; long unsigned int _Nm =
0]'
 3645 |           _M_equal(const _Iterator<_Const>& __x) const
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~^~~

  parent reply	other threads:[~2021-05-17  4:50 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-17  3:22 [Bug libstdc++/100631] New: " hewillk at gmail dot com
2021-05-17  3:45 ` [Bug libstdc++/100631] " hewillk at gmail dot com
2021-05-17  4:50 ` hewillk at gmail dot com [this message]
2021-05-17 10:29 ` ppalka at gcc dot gnu.org
2021-05-17 12:32 ` rs2740 at gmail dot com
2021-05-17 13:34 ` hewillk at gmail dot com
2021-05-18  4:35 ` cvs-commit at gcc dot gnu.org
2021-05-18  5:32 ` hewillk at gmail dot com
2021-05-18 13:50 ` ppalka at gcc dot gnu.org
2021-05-18 14:22 ` cvs-commit at gcc dot gnu.org
2021-06-10 18:54 ` cvs-commit at gcc dot gnu.org
2021-06-10 18:54 ` cvs-commit at gcc dot gnu.org
2021-06-10 18:57 ` cvs-commit at gcc dot gnu.org
2021-06-10 18:58 ` cvs-commit at gcc dot gnu.org
2021-06-10 18:58 ` ppalka at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-100631-4-uGi5yf6mEW@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).