]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: use concrete return type for std::forward_like
authorPatrick Palka <ppalka@redhat.com>
Sat, 3 Aug 2024 13:05:05 +0000 (09:05 -0400)
committerPatrick Palka <ppalka@redhat.com>
Sat, 3 Aug 2024 13:05:05 +0000 (09:05 -0400)
commit8256d5c0097dff00f9bdf9ee0c9d53bd7cec2802
treed59e68a9a9566777a5c4295ece90d7c1c753b69d
parentdb9834aead7629c3f8d640fa546fdc84780c354a
libstdc++: use concrete return type for std::forward_like

Inspired by https://github.com/llvm/llvm-project/issues/101614 this
inverts the relationship between forward_like and __like_t so that
forward_like is defined in terms of __like_t and with a concrete return
type.  __like_t in turn is defined via partial specializations that
pattern match on the const- and reference-ness of T.

This turns out to be more SFINAE friendly and significantly cheaper
to compile than the previous implementation.

libstdc++-v3/ChangeLog:

* include/bits/move.h (__like_impl): New metafunction.
(__like_t): Redefine in terms of __like_impl.
(forward_like): Redefine in terms of __like_t.
* testsuite/20_util/forward_like/2_neg.cc: Don't expect
error outside the immediate context anymore.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/include/bits/move.h
libstdc++-v3/testsuite/20_util/forward_like/2_neg.cc