Title
Return type of std::visit misspecified
Status
c++20
Section
[variant.visit]
Submitter
Tim Song

Created on 2017-05-31.00:00:00 last changed 46 months ago

Messages

Date: 2018-06-12.01:05:16

Proposed resolution:

This wording is relative to N4727.

  1. Modify [variant.visit] as indicated:

    template<class Visitor, class... Variants>
      constexpr see below visit(Visitor&& vis, Variants&&... vars);
    

    […]

    -3- Returns: e(m), where m is the pack for which mi is varsi.index() for all 0 <= i < n. The return type is the type of e(m)decltype(e(m)).

    […]

Date: 2018-06-12.01:05:16

[ 2018-06 Rapperswil: Adopted ]

Date: 2018-02-23.00:00:00

[ 2018-02-23 Moved to Tentatively Ready after 6 positive votes on c++std-lib. ]

Date: 2017-01-15.00:00:00

[ 2017-01-24, Daniel comments ]

This issue should be reviewed in common with LWG 3052.

Date: 2018-01-15.00:00:00

[ 2018-01-11, Thomas Köppe comments and suggests wording ]

The return type of std::visit (originating by P0088R3 accepted during the Oulo 2016 meeting) is currently misspecified and refers only to the common type of all the possible visitation calls, without attention to the value category. This seems unintended, and we should preserve the value category.

Date: 2017-07-12.01:30:31

[ 2017-07 Toronto Monday issue prioritization ]

Priority 2; Matt to provide wording

Date: 2017-05-31.00:00:00

[variant.visit]/1 correctly uses "type and value category", but then p3 describes the return type of visit to be "the common type of all possible INVOKE expressions of the Effects: element." The type of an expression is never a reference type, due to [expr]/5 removing the referenceness "prior to any further analysis", so this wording as written says that visit always returns a non-reference type, which is presumably not the intent.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2018-06-12 01:05:16adminsetmessages: + msg9880
2018-06-12 01:05:16adminsetstatus: voting -> wp
2018-05-06 19:23:13adminsetstatus: ready -> voting
2018-03-03 17:19:23adminsetmessages: + msg9699
2018-03-03 17:19:23adminsetstatus: new -> ready
2018-01-24 20:29:21adminsetmessages: + msg9629
2018-01-14 13:56:30adminsetmessages: + msg9607
2018-01-14 13:56:30adminsetmessages: + msg9606
2017-07-12 01:30:31adminsetmessages: + msg9337
2017-05-31 00:00:00admincreate