This is an archive of the discontinued LLVM Phabricator instance.

[libc++][NFC] Use is_void instead of is_same<void, ...>
AbandonedPublic

Authored by philnik on Jul 13 2022, 7:03 PM.

Details

Reviewers
ldionne
Mordante
var-const
Group Reviewers
Restricted Project

Diff Detail

Event Timeline

philnik created this revision.Jul 13 2022, 7:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 13 2022, 7:03 PM
philnik requested review of this revision.Jul 13 2022, 7:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 13 2022, 7:03 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript

Can you explain what the benefit of this change is? And why the different behaviour of std::same_as and std::is_void_v is not an issue. I'm not even sure we should call this an NFC patch.

In general it would be good to add this kind of information to the commit message/review description.

Can you explain what the benefit of this change is? And why the different behaviour of std::same_as and std::is_void_v is not an issue. I'm not even sure we should call this an NFC patch.

In general it would be good to add this kind of information to the commit message/review description.

The patch is replacing std::is_same with a more specialized version std::is_void. This patch seems fine to me. Two questions:

  • Why do we have the specialized version at all?
  • Why does std::same_as matter here?

Can you explain what the benefit of this change is? And why the different behaviour of std::same_as and std::is_void_v is not an issue. I'm not even sure we should call this an NFC patch.

In general it would be good to add this kind of information to the commit message/review description.

The patch is replacing std::is_same with a more specialized version std::is_void. This patch seems fine to me. Two questions:

std::is_void is less specialized. After the change cv-qualified void types are accepted. https://godbolt.org/z/j66MsThYs

  • Why do we have the specialized version at all?

You mean std::is_void? (If yes, that's required by the Standard.)

  • Why does std::same_as matter here?

Sorry I don't understand the question, can you rephrase it?

Can you explain what the benefit of this change is? And why the different behaviour of std::same_as and std::is_void_v is not an issue. I'm not even sure we should call this an NFC patch.

In general it would be good to add this kind of information to the commit message/review description.

The benefit is that it's a bit easier to read IMO. The different behaviour isn't an issue in the first three files, because it just checks that __make_32_64_or_128_bit_t or the conditional succeeded, which indicate a failure as void. The two tests check that the return type is void. There it isn't a problem, because cv-qualifiers on return types are discarded. IOW const void func(); static_assert(std::is_same_v<void, decltype(func())>); is a correct program.

Can you explain what the benefit of this change is? And why the different behaviour of std::same_as and std::is_void_v is not an issue. I'm not even sure we should call this an NFC patch.

In general it would be good to add this kind of information to the commit message/review description.

The benefit is that it's a bit easier to read IMO. The different behaviour isn't an issue in the first three files, because it just checks that __make_32_64_or_128_bit_t or the conditional succeeded, which indicate a failure as void. The two tests check that the return type is void. There it isn't a problem, because cv-qualifiers on return types are discarded. IOW const void func(); static_assert(std::is_same_v<void, decltype(func())>); is a correct program.

For me it's the opposite; I wonder what const void would mean in that context. The code in charconv and format is written by me and I didn't use is_void_v since to me the current syntax is easier to read.

ldionne added inline comments.Jul 22 2022, 9:08 AM
libcxx/test/std/containers/container.adaptors/queue/queue.defn/emplace.pass.cpp
36

IMO is_same reads better here (and in the other two test files) since it is more symmetric with other tests for the return type, where we check is_same<queue_return_type, SOMETHING>.

philnik abandoned this revision.Jul 24 2022, 7:08 AM