Title
The static_cast expression in convertible_to has the wrong operand
Status
ready
Section
[concept.convertible]
Submitter
Tim Song

Created on 2021-05-26.00:00:00 last changed 1 week ago

Messages

Date: 2021-06-07.17:03:22

Proposed resolution:

This wording is relative to N4885.

  1. Modify [concept.convertible] as indicated:

    template<class From, class To>
      concept convertible_to =
        is_convertible_v<From, To> &&
        requires(add_rvalue_reference_t<From> (&f)()) {
          static_cast<To>(fdeclval<From>());
        };
    
Date: 2021-06-15.00:00:00

[ 2021-06-07; Reflector poll ]

Set status to Tentatively Ready after nine votes in favour during reflector poll.

Date: 2021-05-26.00:00:00

The specification of convertible_to implicitly requires static_cast<To>(f()) to be equality-preserving. Under [concepts.equality] p1, the operand of this expression is f, but what we really want is for f() to be treated as the operand. We should just use declval (which is treated specially by the definition of "operand" for this purpose) instead of reinventing the wheel.

History
Date User Action Args
2021-06-07 17:03:22adminsetmessages: + msg11918
2021-06-07 17:03:22adminsetstatus: new -> ready
2021-05-27 17:22:39adminsetmessages: + msg11861
2021-05-26 00:00:00admincreate