Date
2020-01-05.16:32:39
Message id
10912

Content

Proposed resolution:

This wording is relative to N4835, and also resolves LWG 3151.

  1. Modify [concept.convertible] as indicated:

    -1- Given types From and To and an expression E such that decltype((E)) is add_rvalue_reference_t<From>, convertible_to<From, To> The convertible_to concept requires E an expression of a particular type and value category to be both implicitly and explicitly convertible to some other type To. The implicit and explicit conversions are required to produce equal results.

    template<class From, class To>
      concept convertible_to =
        is_convertible_v<From, To> &&
        requires(add_rvalue_reference_t<From> (&f)()) {
          static_cast<To>(f());
        };
    

    -2- Let FromR be add_rvalue_reference_t<From> and test be the invented function:

    To test(FromR (&f)()) {
      return f();
    }
    

    for some types From and To, and let f be a function with no arguments and return type FromR such that f() is equality-preserving. From and To model convertible_to<From, To> only if:

    1. (2.1) — To is not an object or reference-to-object type, or static_cast<To>(f()) is equal to test(f).

    2. (2.2) — FromR is not a reference-to-object type, or

      1. (2.2.1) — If FromR is an rvalue reference to a non const-qualified type, the resulting state of the object referenced by f() after either above expression is valid but unspecified ([lib.types.movedfrom]).

      2. (2.2.2) — Otherwise, the object referred to by f() is not modified by either above expression.