[libcxx-commits] [PATCH] D108216: [libc++] Formulate _EnableIf in terms of std::enable_if
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Aug 17 09:41:10 PDT 2021
ldionne created this revision.
ldionne requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
I just ran into a compiler error involving __bind_back and some overloads
that were being disabled with _EnableIf. I noticed that the error message
was quite bad and did not mention the reason for the overload being
excluded. Specifically, the error looked like this:
candidate template ignored: substitution failure [with _Args =
<ContiguousView>]: no member named '_EnableIfImpl' in 'std::_MetaBase<false>'
Instead, when using enable_if or enable_if_t, the compiler is clever and
can produce better diagnostics, like so:
candidate template ignored: requirement 'is_invocable_v<
std::__bind_back_op<1, std::integer_sequence<unsigned long, 0>>,
std::ranges::views::__transform::__fn &, std::tuple<PlusOne> &,
ContiguousView>' was not satisfied [with _Args = <ContiguousView>]
Basically, it tries to do a poor man's implementation of concepts, which
is already a lot better than simply complaining about substitution failure.
Hence, this commit does two things:
1. Use enable_if_t instead of _EnableIf whenever possible. That is both more straightforward than using the internal helper, and also leads to better error messages in those cases.
2. Reformulate _EnableIf in terms of enable_if so that pre-C++14 places get better error messages too.
I understand the motivation for _EnableIf's implementation was to improve
compile-time performance, however I believe striving to improve error
messages is even more important for our QOI, hence this patch.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D108216
Files:
libcxx/include/__functional/bind_back.h
libcxx/include/__functional/bind_front.h
libcxx/include/__functional/not_fn.h
libcxx/include/__functional/perfect_forward.h
libcxx/include/__memory/construct_at.h
libcxx/include/array
libcxx/include/bit
libcxx/include/cmath
libcxx/include/deque
libcxx/include/forward_list
libcxx/include/list
libcxx/include/map
libcxx/include/optional
libcxx/include/queue
libcxx/include/set
libcxx/include/stack
libcxx/include/string
libcxx/include/type_traits
libcxx/include/unordered_map
libcxx/include/unordered_set
libcxx/include/vector
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108216.366926.patch
Type: text/x-patch
Size: 73714 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210817/590de2c7/attachment-0001.bin>
More information about the libcxx-commits
mailing list