X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fstructure%2FSGSharedPtr.hxx;h=081d5eb943b1bcb43cf89661228b4477ea94a7ab;hb=10375086ed794770fcb97591ec19c60c0fcdaff1;hp=3de62e6c7cb78819b411e5af6d1feffb31799402;hpb=beca1cbf96b2ca7908b2f50e5462b8208e802278;p=simgear.git diff --git a/simgear/structure/SGSharedPtr.hxx b/simgear/structure/SGSharedPtr.hxx index 3de62e6c..081d5eb9 100644 --- a/simgear/structure/SGSharedPtr.hxx +++ b/simgear/structure/SGSharedPtr.hxx @@ -123,4 +123,51 @@ T* get_pointer(SGSharedPtr const & p) { return p.ptr(); } + +/** + * static_cast for SGSharedPtr + */ +template +SGSharedPtr static_pointer_cast(SGSharedPtr const & r) +{ + return SGSharedPtr( static_cast(r.get()) ); +} + +/** + * Compare two SGSharedPtr objects for equality. + * + * @note Only pointer values are compared, not the actual objects they are + * pointing at. + */ +template +bool operator==(const SGSharedPtr& lhs, const SGSharedPtr& rhs) +{ + return lhs.get() == rhs.get(); +} + +/** + * Compare two SGSharedPtr objects for equality. + * + * @note Only pointer values are compared, not the actual objects they are + * pointing at. + */ +template +bool operator!=(const SGSharedPtr& lhs, const SGSharedPtr& rhs) +{ + return lhs.get() != rhs.get(); +} + +/** + * Compare two SGSharedPtr objects for weak ordering. + * + * @note Only pointer values are compared, not the actual objects they are + * pointing at. + * @note This allows using SGSharedPtr as key in associative containers like for + * example std::map and std::set. + */ +template +bool operator<(const SGSharedPtr& lhs, const SGSharedPtr& rhs) +{ + return lhs.get() < rhs.get(); +} #endif