[PATCH] Implement std::visit<R> for C++2a (P0655R1)
Ville Voutilainen
ville.voutilainen@gmail.com
Fri Apr 5 23:48:00 GMT 2019
On Sat, 6 Apr 2019 at 02:19, Ville Voutilainen
<ville.voutilainen@gmail.com> wrote:
> And this patch fixes the existing visitation so that we don't
> over-eagerly cast to void. The main gist of it is
>
> - else if constexpr (is_same_v<_Result_type, void>)
> + else if constexpr (!__same_return_types &&
> + is_same_v<_Result_type, void>)
>
> and the new ensure-test is adjusted to use void as the return type of
> the first visitor.
..and this patch makes cv void work as the return type. The important
bits are (incrementally)
- is_same_v<_Result_type, void>)
+ is_void_v<_Result_type>)
and
- return __do_visit<false, false>(std::forward<_Visitor>(__visitor),
- std::forward<_Variants>(__variants)...);
+ return (_Res)
+ __do_visit<false, false>(std::forward<_Visitor>(__visitor),
+ std::forward<_Variants>(__variants)...);
and the visit_r test is amended to also test visitation of a visitor
with a const void result, when the visitor
itself does not return void.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: variant-visit_r_3.diff
Type: text/x-patch
Size: 8772 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20190405/84e00967/attachment.bin>
More information about the Libstdc++
mailing list