
20 Oct
2009
20 Oct
'09
9:44 p.m.
Andrey Semashev wrote:
I think the performance cost of checking a reference or pointer for validity and checking some property in the error_code instance will be the same. After all, in both cases it comes down to a single comparison of two integers. Even if referencing the global default instance does add overhead, I bet it is negligible. No, it isn't. The null pointer will be in a register, while the global object might not even be in the cache. And this for functions that are called by the thousands per second on a busy server.
Detlef PS: This was one of the main reasons why the POSIX/C++ group is in favour of the pointer.