[libcxx-commits] [PATCH] D116388: [libc++] Properly handle specializations of std::is_placeholder.
Arthur O'Dwyer via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Dec 30 13:09:14 PST 2021
Quuxplusone updated this revision to Diff 396707.
Quuxplusone marked an inline comment as done.
Quuxplusone added a comment.
...and I forgot to answer @ldionne's question about conformingness, so I'll do it here!
My understanding is that `std::bind` is just massively underspecified. For example, https://eel.is/c++draft/func.bind.isbind says
> The function template `bind` uses `is_bind_expression` to detect subexpressions. [...] A program may specialize this template for a program-defined type `T` to have a base characteristic of `true_type` to indicate that `T` should be treated as a subexpression in a `bind` call.
But, like, //how// does it use `is_bind_expression` to detect subexpressions? and what does it mean to "be treated as a subexpression"? and what happens if this template is specialized to have a base characteristic of something-other-than-`true_type`? None of this is written out. But I think clearly the //intent// is what's happening in this PR: a single specialization for `T` should magically apply to all cv-qualifications and value-categories of `T`.
It is also never really specified what should happen if the user //queries// `std::is_placeholder_v<U>` for any particular `U`; `is_placeholder` is fundamentally a mechanism for //customizing// the library's behavior, not for //querying// it.
#include <functional>
struct P {};
template<> struct std::is_placeholder<P> : std::true_type {};
static_assert(std::is_placeholder_v<const P>); // unspecified
Here's the exhaustive rundown: https://godbolt.org/z/jcTnqY6vb
There's some implementation divergence, but not as much as I originally thought.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D116388/new/
https://reviews.llvm.org/D116388
Files:
libcxx/include/__functional/bind.h
libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp
libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp
libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/specialization.pass.cpp
libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.isplace/is_placeholder.pass.cpp
libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.isplace/specialization.pass.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116388.396707.patch
Type: text/x-patch
Size: 8571 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211230/dd945a28/attachment-0001.bin>
More information about the libcxx-commits
mailing list