I encountered a somewhat odd "shared pointer" usage. As far as I know, shared pointers are written out as
std::shared_ptr<void()> pointy(fun, del);
However, I have a case where I have an interface IGenericResult (which all different result-classes implement). I found a place where it simply has "SharedPtr" added to the end of the name. Like this;
IGenericResultSharedPtr result = databasePointer->getLatestResult();
result->getTimestamp(); // Example of usage
It doesn't seem as if there is any defined class/interface/header/anything named IGenericResultSharedPtr so I can only assume it's something built into C++ (currently using version C++11 I think).
Is this the same thing as the std::shared_ptr (and if it is, how would I declare it in the std syntax)? If it's not the same thing, what differences are there?
There is no such thing as "if the type name is XYZSharedPtr
, it is instead std::shared_ptr<XYZ>
" inbuilt into C++.
The authors of the code created a type alias somewhere, either
using IGenericResultSharedPtr = std::shared_ptr<IGenericResult>;
or
typedef std::shared_ptr<IGenericResult> IGenericResultSharedPtr;
(or possibly wrapped in a macro - who knows). Ask your IDE to find the definition :)