C++17 feature proposal: Allow std::data, std::size, std::empty

84 views
Skip to first unread message

Daniel Cheng

unread,
Jan 6, 2022, 4:12:47 PM1/6/22
to cxx
We already have our own backported versions of std::data and std::size; let's remove them and replace them with the standard version. We don't have a std::empty, but allowing it alongside the other two makes sense to me.

Daniel

Jeremy Roman

unread,
Jan 6, 2022, 4:21:31 PM1/6/22
to Daniel Cheng, cxx
We do have base::empty. More generally I think anything from cxx17_backports.h should likely move to the genuine article. :)

On Thu, Jan 6, 2022 at 4:12 PM Daniel Cheng <dch...@chromium.org> wrote:
We already have our own backported versions of std::data and std::size; let's remove them and replace them with the standard version. We don't have a std::empty, but allowing it alongside the other two makes sense to me.

Daniel

--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAF3XrKq8-MC9uPQQZ0w37tBsO0TjrS0%2BgL-VoUM%3DTsnQjaEXvg%40mail.gmail.com.

Avi Drissman

unread,
Jan 6, 2022, 4:26:13 PM1/6/22
to Jeremy Roman, Daniel Cheng, cxx
Strong concerns for the general statement about cxx17_backports. The items in that file should be addressed one at a time to ensure we don't backslide on undefined behavior (looking at base::clamp specifically).

+1 for migrating our versions to std for the specific functions std::data, std::size, std::empty.

Lei Zhang

unread,
Jan 6, 2022, 4:27:08 PM1/6/22
to Avi Drissman, Jeremy Roman, Daniel Cheng, cxx

Peter Kasting

unread,
Jan 6, 2022, 4:43:33 PM1/6/22
to Avi Drissman, Jeremy Roman, Daniel Cheng, cxx

Daniel Cheng

unread,
Jan 6, 2022, 4:47:07 PM1/6/22
to Avi Drissman, Jeremy Roman, cxx
Agreed: I saw the CHECK() in base::clamp() and that's why I specifically didn't broaden this proposal to include all of them. And if we exclude base::clamp(), then lumping in other random functions into this proposal seemed a bit too random.

Daniel

Peter Kasting

unread,
Feb 21, 2022, 11:09:32 PM2/21/22
to Daniel Cheng, cxx
It looks like we had agreement to do the narrow change here, but this didn't land?

PK

On Thu, Jan 6, 2022 at 1:12 PM Daniel Cheng <dch...@chromium.org> wrote:
We already have our own backported versions of std::data and std::size; let's remove them and replace them with the standard version. We don't have a std::empty, but allowing it alongside the other two makes sense to me.

Daniel

--

Daniel Cheng

unread,
Feb 22, 2022, 1:39:27 AM2/22/22
to Peter Kasting, cxx
Let me create a bug here. I think I was planning on doing this in one atomic CL, but given the variants, it's probably better to stage this one out into multiple CLs. I'll send a CL to update the wording though.

Daniel

Daniel Cheng

unread,
Mar 7, 2022, 6:58:24 PM3/7/22
to Peter Kasting, cxx
This should be done now. I need to clean up a few header files, but it looks like the last change to delete base::{data,empty,size} isn't going to get reverted. Thanks to thestig@ for all the reviews!

Daniel

Lei Zhang

unread,
Mar 7, 2022, 6:59:31 PM3/7/22
to Daniel Cheng, Peter Kasting, cxx
Reply all
Reply to author
Forward
0 new messages