[concept.convertible] (original) (raw)

18 Concepts library [concepts]

18.4.4 Concept convertible_­to [concept.convertible]

Given types From and To and an expression E such thatdecltype((E)) is add_­rvalue_­reference_­t<From>,convertible_­to<From, To> requires Eto be both implicitly and explicitly convertible to type To.

The implicit and explicit conversions are required to produce equal results.

template<class From, class To> concept [convertible_­to](#concept:convertible%5Fto "18.4.4 Concept convertible_­to [concept.convertible]") = is_convertible_v<From, To> && requires(add_rvalue_reference_t<From> (&f)()) { static_cast<To>(f());};

Let FromR be add_­rvalue_­reference_­t<From> andtest be the invented function:To test(FromR (&f)()) { return f();} and let f be a function with no arguments and return type FromRsuch that f() is equality-preserving.

Types From and To model convertible_­to<From, To>only if: