[PATCH] c++: Diagnose visitors with different return types for std::visit [PR95904]
Ville Voutilainen
ville.voutilainen@gmail.com
Mon Sep 28 22:12:50 GMT 2020
Not completely tested yet. This does fix the problem of converting
incompatible pointer-to-function types, and thus gets rid of the suggestion
that compiling the code with -fpermissive is a possibility. There
is a special-casing for visit() for visitation of a single variant, and there
we don't even instantiate the whole table mechanism. We should really
entertain the possibility of flattening the whole visitation table; then
this check could (at least in theory) be uniformly written as just
an iteration of all table elements, which is not so convenient to do
with the nested multitable. This seems like a worthy incremental
improvement to me.
2020-09-29 Ville Voutilainen <ville.voutilainen@gmail.com>
PR libstdc++/95904
* include/std/variant (__same_types): New.
(__check_visitor_result): Likewise.
(__check_visitor_results): Likewise.
(visit(_Visitor&&, _Variants&&...)): Use __check_visitor_results
in case we're visiting just one variant.
(__gen_vtable_impl</*base case*/>::_S_apply):
Check the visitor return type.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr95904.diff
Type: text/x-patch
Size: 3478 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20200929/e7e77a22/attachment-0001.bin>
More information about the Libstdc++
mailing list