====== dynamictracer ====== This sunday, we developed a really cool dynamic tracer for [[http://aspectc.com|AspectC++]]. #include using namespace std; struct X { X (...) {} }; typedef char magically_sized_type[43564367]; magically_sized_type &operator << (ostream &os, X); template struct detector { enum { RET = (sizeof (cout << T()) == sizeof (magically_sized_type)) }; }; template struct Printer { static void print (ostream &out, const T &arg) { out << arg << endl; } }; template struct Printer { static void print (ostream &out, const T &arg) { out << "Unprintable type, addr: " << &arg << "size: " << sizeof (T) << endl; } }; template void print (ostream &out, const T &arg) { Printer::RET>::print (out, arg); } int main() { print(std::cout, "Teststring"); print(std::cout, 4711); print(std::cout, 11.1); } The interesting part about this pattern is, that it uses the ''operator<<'' for types which have such an operator, and an alternate implementation, which doesn't need it. I need it for implementing a generic tracer. Please tell me if someone can construct a type or construction, which fails for this tracer. ~~DISCUSSION~~ {{tag>tech english aop uni}}