18 Concepts library [concepts]

18.4 Language-related concepts [concepts.lang]

18.4.4 Concept ConvertibleTo [concept.convertibleto]

The ConvertibleTo concept requires an expression of a particular type and value category to be both implicitly and explicitly convertible to some other type.
The implicit and explicit conversions are required to produce equal results.
template<class From, class To> concept ConvertibleTo = is_convertible_v<From, To> && 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 ([lib.types.movedfrom]).
    • Otherwise, the object referred to by f() is not modified by either above expression.