Returning const by-value

Hi,

const ON_wString Name() const;

what is the point of the return value constness? that is used wherever ON_wString::EmptyString may be returned. But to what purpose ? the caller is guaranteed to get a copy here. The only thing that happens is a complete prevention of the move semantics.

Hi @Nikolay,

It is not recommended to return a const value. Such older advice is now obsolete; it does not add value, and it interferes with move semantics.

Perhaps this is true today. But openNURBS has been around a long time. And we cannot remove the const without breaking tools that call this. So it is what it is, as they say.

– Dale

I can almost agree with that - in one case (msvc, a .dll binary, and clients plugging the new version without recompiling). And I guess that is the reason you have also .NameAsPointer() in many places, which I’m going to switch to.

It is a very strong commitment to keep the ABI stable for so long. I’d rather break it on every major version.

Thanks, Dale