For example, I have such a smart pointer:
template <typename T>
class SmartPointer
{
public:
....
T* operator & () { return m_p; }
private:
T* m_p;
}
void foo()
{
std::vector<SmartPointer<int> >vec;
vec.push_back(....);
vec.resize(.....);
......
}
Is this usage safe? I try it in MINGW4.4, It work ok....
In fact, those code is use work for COM, when I wanted to get a object, I need to do these
SmpartPointer<COMObj> spObj;
HRESULT hr = xxxxx->QueryInterface(&spObj);
then i wanted to store the pointer in a vector, so
std::vector<SmpartPointer<COMObj> >vec;
.....