Re:Why C++ Sails When the Vasa Sank [pdf]
by mmaldacker on Tuesday June 24, 2014 @04:27AM
(#7936684)
With C++11 you don't need the safe bool idiom anymore, you can simply define a "explicit operator bool() const". Since the conversion needs to be explicit, you won't have nasty surprises but it can still be used in an if (or while) normally as in this case the explicit conversion will be used implicitly. In other words, it works exactly like the safe bool idiom but is much easier to write.
[ Parent
| on HN ]
There are no comments on this comment yet.