<div dir="ltr"><div>This is just for discussion!</div><div><br></div><div>However if someone gives me guidance I am willing to do the work.</div><div><br></div><div>While building VTK I noticed a warning regarding the deprecation of std::auto_ptr.</div><div><br></div><div>It seems std::auto_ptr is deprecated since C++11 and will most likely be removed in C++17.</div><div>See: <a href="http://en.cppreference.com/w/cpp/memory/auto_ptr">http://en.cppreference.com/w/cpp/memory/auto_ptr</a></div><div>and: <a href="https://en.wikipedia.org/wiki/C%2B%2B17">https://en.wikipedia.org/wiki/C%2B%2B17</a></div><div><br></div><div>From a quick read it seems that std::unique_ptr is the preferred replacement. However there is also an std::shared_ptr which is a smart pointer retaining shared ownership of an object through a pointer.</div><div><br></div><div>A cursory search reveals that the following VTK sources use std::auto_ptr:</div><div>./ThirdParty/jsoncpp/vtkjsoncpp/jsoncpp.cpp</div><div>./IO/XMLParser/vtkXMLDataParser.cxx</div><div>./IO/XML/vtkXMLWriter.cxx</div><div>./Common/DataModel/vtkDispatcher_Private.h</div><div><br></div><div>It seems ./Utilities/KWSys/vtksys/<a href="http://auto_ptr.hxx.in">auto_ptr.hxx.in</a> implements its own version of auto_ptr, however this is not used in the above files.</div><div><br></div><div>I'll freely admit that I am out of my depth here but in the case of:</div><div>./IO/XMLParser/vtkXMLDataParser.cxx</div><div>./IO/XML/vtkXMLWriter.cxx</div><div>To me, it seems that std::unique_ptr would be the replacement.</div><div><br></div><div>In the case of:</div><div>./Common/DataModel/vtkDispatcher_Private.h</div><div>I'm not so sure. Especially since a swap seems to occur in line 309:</div><div> Functor& operator=(const Functor& rhs)</div><div><br></div><div>So I have two questions:</div><div>1) How do we handle future proofing in this case? Most importantly, we need to keep std::auto_ptr for older compilers but should move to either std::unique_ptr and/or possibly std::shared_ptr. Is there a define that we can use?</div><div><br></div><div>Finally:</div><div>2) vtkSmartPointer ... how does this fit in? To me it seems this similar to std::shared_ptr. Could vtkSmartPointer just be a wrapper around std::shared_ptr for new compilers (C++11 and newer)?</div><div><br></div><div>Regards</div><div>   Andrew</div><div><br></div><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">___________________________________________<br>Andrew J. P. Maclean<br><br>___________________________________________</div>
</div>