cxx-benchmarks/test-const-ref-results.cpp

23 regels
449 B
C++

2014-07-19 13:35:25 +00:00
#include <algorithm>
#include <memory>
#include <iostream>
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<uintptr_t>(&a) < reinterpret_cast<uintptr_t>(&b);
}
int main() {
auto const& m =
// std::max(*std::make_shared<C>(), *std::make_shared<C>());
std::max(C(), C());
std::cout << m.valid << "\n";
}