diff --git a/track.cpp b/track.cpp index a2c39de..a3a2d95 100644 --- a/track.cpp +++ b/track.cpp @@ -1,3 +1,4 @@ +#include #include #include // requires C++23 to compile @@ -17,16 +18,22 @@ public: ret.counter--; return ret; } - friend std::ostream &operator<<(std::ostream &lhs, A const &rhs) { - lhs << rhs.counter; - return lhs; - } + // friend std::ostream &operator<<(std::ostream &lhs, A const &rhs) { + // lhs << rhs.counter; + // return lhs; + // } + operator long long() { return counter; } }; int main(void) { A a; - std::cout << a[] << std::endl; - std::cout << a[]() << std::endl; - std::cout << a[]()() << std::endl; + assert(a == 0); + assert(a[] == -1); + assert(a[]() == 0); + assert(a[]()() == 1); + int i = a; + assert(i == 0); + i = a()()(); + assert(i == 3); return 0; }