#include #include #include class C { public: int valid; C() : valid(1) { } ~C() { valid = 0; } }; /* some "random" comparison, doesn't matter */ bool operator<(C const& a, C const& b) { return reinterpret_cast(&a) < reinterpret_cast(&b); } int main() { auto const& m = // std::max(*std::make_shared(), *std::make_shared()); std::max(C(), C()); std::cout << m.valid << "\n"; }