
28 Aug
2006
28 Aug
'06
3:10 p.m.
Le lundi 28 août 2006 à 09:49 -0400, Beman Dawes a écrit :
extern error_code throw_on_error;
Then only a single signature is required:
whatever foo( error_code & ec = throw_on_error );
On an error, the implementation of foo throws if ec != &throw_on_error, otherwise it sets ec to the appropriate error_code and returns without throwing.
I often use this idiom and I like it. You may however encounter problems on systems that have difficulties mixing static and shared libraries. It may be safer to stick with this version of the idiom: whatever foo(error_code *ec = NULL); Best regards, Guillaume