.. _convertible_to: ******************** meta::convertible_to ******************** Defined in header ````. .. code-block:: cpp template concept convertible_to = std::is_convertible_v && requires(From (&f)()) { static_cast(f()); }; Pre-C++20 implementation of the :concept:`convertible_to` concept. ---- Differences with the C++20 version ================================== * Checks template arguments before calling :cpp:`std::is_convertible_v `, which is not SFINAE-friendly. Concept emulation ================= .. code-block:: cpp namespace mgs { namespace meta { template struct is_convertible_to { /* ... */ }; template constexpr auto is_convertible_to_v = is_convertible_to::value; template > using convertible_to = From; } // namespace meta } // namespace mgs Example ======= .. code-block:: cpp #include using namespace mgs::meta; struct A {}; struct B { explicit operator A(); }; struct C { operator A(); }; static_assert(is_convertible_to_v, ""); static_assert(!is_convertible_to_v, "");