ggris Posted December 4, 2015 Share Posted December 4, 2015 It is pretty common for smart pointers nowadays to implement bool() operator. (See std:: for instance) Maybe you could add to UniginePtr.h something like /** * Test if the pointer object owns a resource */ UNIGINE_INLINE explicit operator bool() const { return (this->get() != nullptr); } With this you can use safe patterns like : if (Unigine::Ptr<Something> ptr = methodToGetPtr()) { // ptr is guaranteed not to be nullptr here // Do something with ptr ... } // ptr is not defined here so cannot be misused. 1 Link to comment
silent Posted December 4, 2015 Share Posted December 4, 2015 Hi Guillaume, Great suggestion! Added it to our internal TODO list. Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Recommended Posts