I have an iterator which contains the following functions:
...
T &operator*() { return *_i; }
std::shared_ptr<T> operator->() { return _i; }
private:
std::shared_ptr<T> _i;
...
How do I get a shared pointer to the internally stored _i?
std::shared_ptr<Type> item = ???
Should I do:
MyInterfaceIterator<Type> i;
std::shared_ptr<Type> item = i.operator->();
Or should I rewrite operator*()?
If you can edit the code you can add a simple
getfunction that return the internalshared_ptr!! It’s better than callingoperator->directly, isn’t it??