7 Concepts library [concepts.lib]

7.3 Core language concepts [concepts.lib.corelang]

7.3.4 Concept ConvertibleTo [concepts.lib.corelang.convertibleto]

template <class T, class U> concept bool ConvertibleTo = is_convertible<From, To>::value && // see below requires(From (&f)()) { static_cast<To>(f()); };

Let test be the invented function:

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

and let f be a function with no arguments and return type From such that f() is equality preserving. ConvertibleTo<From, To> is satisfied only if:

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

  • From is not a reference-to-object type, or

    • If From 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 ( ISO/IEC 14882:2014 §[lib.types.movedfrom]).

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

There need not be any subsumption relationship between ConvertibleTo<From, To> and is_convertible<From, To>::value.