libstdc++-v3/ChangeLog: PR libstdc++/95904 * include/std/variant (__deduce_visit_result): Add a nested ::type. (__gen_vtable_impl</*base case*/>::_S_apply): Check the visitor return type. (__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. * testsuite/20_util/variant/visit_neg.cc: Adjust.