Fix std::visit to support arbitrary callables
authorJonathan Wakely <jwakely@redhat.com>
Tue, 9 Apr 2019 18:50:43 +0000 (19:50 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Tue, 9 Apr 2019 18:50:43 +0000 (19:50 +0100)
commit8701cb5e0dc0a3b949bb28f3ff9ee5bae98c47fe
tree0bd9c3d6f3251d67f4acf2bfbdd6917989e32da5
parentbc203bf0dab0cdb39370357bc3244999a2f9e419
Fix std::visit to support arbitrary callables

The __visitor_result_type helper didn't use std::invoke and so didn't
compile when the visitor was a pointer-to-member rather than a function
object. Use std::invoke_result instead.

* include/std/variant (__variant_idx_cookie): Add member type.
(__visitor_result_type): Remove.
(__do_visit): Use invoke_result instead of __visitor_result_type.
* testsuite/20_util/variant/visit.cc: New test.

From-SVN: r270237
libstdc++-v3/ChangeLog
libstdc++-v3/include/std/variant
libstdc++-v3/testsuite/20_util/variant/visit.cc [new file with mode: 0644]