#include #include #include #include #include #include #include #include #include #include #include #include #include struct NoTriviallyConstructible { public: NoTriviallyConstructible(int one, float two) {} int vl = 1; private: NoTriviallyConstructible() = delete; }; struct NoCopyConstructible { public: NoCopyConstructible() = default; int vl = 1; private: NoCopyConstructible(const NoCopyConstructible&) = delete; void operator=(const NoCopyConstructible&) = delete; }; template struct Convert; template <> struct Convert { int operator()(const NoTriviallyConstructible& as) { return as.vl; } }; template <> struct Convert { NoTriviallyConstructible operator()(const NoTriviallyConstructible& as) { return NoTriviallyConstructible(as.vl, 0.1); } }; template class is_customly_convertible { template static char test(decltype(&Convert::operator())); template static int test(...); public: enum { value = sizeof(test(0)) == sizeof(char) }; };