On Tue, Oct 12, 2010 at 2:40 PM, Branko Čibej <[email protected]> wrote:
> On 12.10.2010 20:35, Hyrum K. Wright wrote:
>> 1) Return everything by value
>> Pros: simpler memory management, less overhead (?)
>> Cons: doesn't allow the return of NULL values, need to establish
>> conventions to represent NULL objects (an isNull() method?)
>
> Meh.
>
> inline operator bool() const { return (this->c_struct_pointer != 0); }
That works great for our own types, but what about stuff like std::string?
inline std::string getAuthor() const { return std::string(ptr->author); }
doesn't go over so well when ptr->author is NULL. If returning by
value, we *have* to return a string, but there just isn't any way to
indicate the null string.
-Hyrum