Friday 9 December 2005 — This is 19 years old. Be careful.
For the second time in two weeks, I happened upon Marshall Cline’s C++ FAQ Lite. I’m not sure why it’s called “Lite”, because it is a huge list of hard questions, expertly answered. I thought I had shone a flashlight into every dark corner C++ had to offer, but I learned a few things poking around.
For example, in the answer to What does throw; mean? Where would I use it?, I learned that you can use throw even when not lexically nested in a catch:
void handleException()
{
try {
throw;
}
catch (MyException& e) {
// ...code to handle MyException...
}
catch (YourException& e) {
// ...code to handle YourException...
}
}
void f()
{
try {
// ...something that might throw...
}
catch (...) {
handleException();
}
}
(We can argue over whether this is a good idea: my point is I didn’t even know it was possible in the language.) And in What should be done with macros that contain if? (and the three questions that follow it), Cline explores all of the fiddly details that you need to consider when writing macros of any interesting complexity.
The whole FAQ is amazing like this: chock-full of top-notch technical detail.
Comments
"At last count, the C++ FAQ Book is 500% larger than the C++ FAQ Lite."
I'm sure there's a design somewhere I can complicate^H^H^H^H^H^H^H improve armed with this knowledge..
Add a comment: