]> gcc.gnu.org Git - gcc.git/commit
libstdc++: Do not use deduced return type for std::visit [PR 100384]
authorJonathan Wakely <jwakely@redhat.com>
Tue, 4 May 2021 11:16:46 +0000 (12:16 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 6 May 2021 13:05:34 +0000 (14:05 +0100)
commite99763ee6da8e378073b847243d9ac2538903534
treea4e1bb19d32bd0f12857faaac49d0c5e85e3c721
parentd22de093a91a1488785907d69020b5e86c96d5b5
libstdc++: Do not use deduced return type for std::visit [PR 100384]

This avoids errors outside the immediate context when std::visit is an
overload candidate because of ADL, but not actually viable.

The solution is to give std::visit a non-deduced return type. New
helpers are introduced for that, and existing ones refactored slightly.

libstdc++-v3/ChangeLog:

PR libstdc++/100384
* include/std/variant (__get_t): New alias template yielding the
return type of std::get<N> on a variant.
(__visit_result_t): New alias template yielding the result of
std::visit.
(__same_types): Move into namespace __detail::__variant.
(__check_visitor_results): Likewise. Use __invoke_result_t and
__get_t.
(__check_visitor_result): Remove.
(visit): Use __visit_result_t for return type.
* testsuite/20_util/variant/100384.cc: New test.

(cherry picked from commit af5b2b911dd80ae9cc87404b7e7ab807cf6655d4)
libstdc++-v3/include/std/variant
libstdc++-v3/testsuite/20_util/variant/100384.cc [new file with mode: 0644]
This page took 0.05978 seconds and 6 git commands to generate.