[Xapian-discuss] xapian/output.h
Olly Betts
olly at survex.com
Sat Oct 23 02:21:16 BST 2004
Including xapian.h provides helper functions (from xapian/output.h)
which allow you to write:
cout << object << endl;
Instead of:
cout << object.get_description() << endl;
But it's rare that you actually want to do this. The get_description
output isn't meaningful to an end user, but you might add such a call
when trying to debug (you can also invoke get_description on objects in
the debugger of course, but sometimes "debugging with printf" is the
best approach).
But by providing this mechanism, we set a trap for the unwary. With
these helpers, mistakes like this will compile successfully, and the
error will only be caught at runtime:
MSetIterator m;
cout << m << endl; // I meant to write *m!
Without the helpers, this is an error at compile time.
We use these helpers internally for the debug tracing output, but
they can easily be moved into an internal header.
Thoughts? Does anybody actually use these helpers?
Cheers,
Olly
More information about the Xapian-discuss
mailing list