
3 Dec
2008
3 Dec
'08
6:38 a.m.
Ion GaztaƱaga wrote:
I think there is no overhead.
The overhead I'm talking about is that allowing an empty state in the object might have a cost. A simple example is that if you have a function release(resource&), that releases a valid resource, and you want to wrap that resource using RAII, you have to write the destructor as if(!is_empty) release(res); instead of simply release(res); So you need to maintain a boolean (size overhead) and perform a branching (runtime overhead). Usually, however, at least the size overhead can be eliminated since there is a special resource value reserved for the null resource.