Fix visit<R> for variant.
authorVille Voutilainen <ville.voutilainen@gmail.com>
Mon, 8 Apr 2019 19:45:48 +0000 (22:45 +0300)
committerVille Voutilainen <ville@gcc.gnu.org>
Mon, 8 Apr 2019 19:45:48 +0000 (22:45 +0300)
commit3d01c7c2f20ffc062d01a525b8e567931c2b089c
treebfb9c683a02f50f55e7e54b9010f95a168dd8b3e
parent15f4769a12dd1640fcf6608c34eea46d8da86fbb
Fix visit<R> for variant.

* include/std/variant (__do_visit): Add a template parameter
for enforcing same return types for visit.
(__gen_vtable_impl): Likewise.
(_S_apply_single_alt): Adjust.
(__visit_invoke_impl): New. Handle casting to void.
(__do_visit_invoke): New. Enforces same return types.
(__do_visit_invoke_r): New. Converts return types.
(__visit_invoke): Adjust.
(__gen_vtable):  Add a template parameter for enforcing
same return types for visit.
* testsuite/20_util/variant/visit_r.cc: Add a test for a visitor with
different return types.
* testsuite/20_util/variant/visit_neg.cc: New. Ensures that
visitors with different return types don't accidentally
compile with regular visitation.

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