From b08985ac249a58c548e17bf5fbbf7f3852de4717 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 13 Feb 2016 13:36:58 +0100 Subject: [PATCH] Don't use std::auto_ptr<> in the test to avoid warnings When compiling with g++ or clang in C++11 mode, the use of std::auto_ptr<> triggers warnings about its deprecation, so replace it with wxScopedPtr<> as this is simpler than choosing between auto_ptr<> and unique_ptr<>. --- tests/archive/archivetest.cpp | 43 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/tests/archive/archivetest.cpp b/tests/archive/archivetest.cpp index b7801275ef..d9b5568adf 100644 --- a/tests/archive/archivetest.cpp +++ b/tests/archive/archivetest.cpp @@ -20,13 +20,13 @@ #include "archivetest.h" #include "wx/dir.h" +#include "wx/scopedptr.h" #include #include #include #include using std::string; -using std::auto_ptr; // Check whether member templates can be used @@ -550,7 +550,7 @@ TestEntry& ArchiveTestCase::Add(const char *name, template void ArchiveTestCase::CreateArchive(wxOutputStream& out) { - auto_ptr arc(m_factory->NewStream(out)); + wxScopedPtr arc(m_factory->NewStream(out)); TestEntries::iterator it; OnCreateArchive(*arc); @@ -578,7 +578,7 @@ void ArchiveTestCase::CreateArchive(wxOutputStream& out) if ((choices & 2) || testEntry.IsText()) { // try PutNextEntry(EntryT *pEntry) - auto_ptr entry(m_factory->NewEntry()); + wxScopedPtr entry(m_factory->NewEntry()); entry->SetName(name, wxPATH_UNIX); if (setIsDir) entry->SetIsDir(); @@ -692,8 +692,8 @@ template void ArchiveTestCase::ModifyArchive(wxInputStream& in, wxOutputStream& out) { - auto_ptr arcIn(m_factory->NewStream(in)); - auto_ptr arcOut(m_factory->NewStream(out)); + wxScopedPtr arcIn(m_factory->NewStream(in)); + wxScopedPtr arcOut(m_factory->NewStream(out)); EntryT *pEntry; const wxString deleteName = wxT("bin/bin1000"); @@ -705,7 +705,7 @@ void ArchiveTestCase::ModifyArchive(wxInputStream& in, arcOut->CopyArchiveMetaData(*arcIn); while ((pEntry = arcIn->GetNextEntry()) != NULL) { - auto_ptr entry(pEntry); + wxScopedPtr entry(pEntry); OnSetNotifier(*entry); wxString name = entry->GetName(wxPATH_UNIX); @@ -750,7 +750,7 @@ void ArchiveTestCase::ModifyArchive(wxInputStream& in, // try adding a new entry TestEntry& testEntry = Add(newName.mb_str(), newData); - auto_ptr newentry(m_factory->NewEntry()); + wxScopedPtr newentry(m_factory->NewEntry()); newentry->SetName(newName); newentry->SetDateTime(testEntry.GetDateTime()); newentry->SetSize(testEntry.GetLength()); @@ -773,7 +773,7 @@ void ArchiveTestCase::ExtractArchive(wxInputStream& in) typedef std::list Entries; typedef typename Entries::iterator EntryIter; - auto_ptr arc(m_factory->NewStream(in)); + wxScopedPtr arc(m_factory->NewStream(in)); int expectedTotal = m_testEntries.size(); EntryPtr entry; Entries entries; @@ -982,7 +982,7 @@ void ArchiveTestCase::TestIterator(wxInputStream& in) typedef std::list ArchiveCatalog; typedef typename ArchiveCatalog::iterator CatalogIter; - auto_ptr arc(m_factory->NewStream(in)); + wxScopedPtr arc(m_factory->NewStream(in)); size_t count = 0; #ifdef WXARC_MEMBER_TEMPLATES @@ -994,7 +994,7 @@ void ArchiveTestCase::TestIterator(wxInputStream& in) #endif for (CatalogIter it = cat.begin(); it != cat.end(); ++it) { - auto_ptr entry(*it); + wxScopedPtr entry(*it); count += m_testEntries.count(entry->GetName(wxPATH_UNIX)); } @@ -1011,7 +1011,7 @@ void ArchiveTestCase::TestPairIterator(wxInputStream& in) typedef std::map ArchiveCatalog; typedef typename ArchiveCatalog::iterator CatalogIter; - auto_ptr arc(m_factory->NewStream(in)); + wxScopedPtr arc(m_factory->NewStream(in)); size_t count = 0; #ifdef WXARC_MEMBER_TEMPLATES @@ -1023,7 +1023,7 @@ void ArchiveTestCase::TestPairIterator(wxInputStream& in) #endif for (CatalogIter it = cat.begin(); it != cat.end(); ++it) { - auto_ptr entry(it->second); + wxScopedPtr entry(it->second); count += m_testEntries.count(entry->GetName(wxPATH_UNIX)); } @@ -1040,7 +1040,7 @@ void ArchiveTestCase::TestSmartIterator(wxInputStream& in) typedef typename ArchiveCatalog::iterator CatalogIter; typedef wxArchiveIterator > Iter; - auto_ptr arc(m_factory->NewStream(in)); + wxScopedPtr arc(m_factory->NewStream(in)); #ifdef WXARC_MEMBER_TEMPLATES ArchiveCatalog cat((Iter)*arc, Iter()); @@ -1071,7 +1071,7 @@ void ArchiveTestCase::TestSmartPairIterator(wxInputStream& in) typedef wxArchiveIterator > > PairIter; - auto_ptr arc(m_factory->NewStream(in)); + wxScopedPtr arc(m_factory->NewStream(in)); #ifdef WXARC_MEMBER_TEMPLATES ArchiveCatalog cat((PairIter)*arc, PairIter()); @@ -1099,8 +1099,8 @@ void ArchiveTestCase::ReadSimultaneous(TestInputStream& in) // create two archive input streams TestInputStream in2(in); - auto_ptr arc(m_factory->NewStream(in)); - auto_ptr arc2(m_factory->NewStream(in2)); + wxScopedPtr arc(m_factory->NewStream(in)); + wxScopedPtr arc2(m_factory->NewStream(in2)); // load the catalog #ifdef WXARC_MEMBER_TEMPLATES @@ -1192,7 +1192,7 @@ protected: void CreateArchive(wxOutputStream& out); void ExtractArchive(wxInputStream& in); - auto_ptr m_factory; // factory to make classes + wxScopedPtr m_factory; // factory to make classes int m_options; // test options }; @@ -1232,7 +1232,7 @@ void CorruptionTestCase::runTest() void CorruptionTestCase::CreateArchive(wxOutputStream& out) { - auto_ptr arc(m_factory->NewStream(out)); + wxScopedPtr arc(m_factory->NewStream(out)); arc->PutNextDirEntry(wxT("dir")); arc->PutNextEntry(wxT("file")); @@ -1241,8 +1241,8 @@ void CorruptionTestCase::CreateArchive(wxOutputStream& out) void CorruptionTestCase::ExtractArchive(wxInputStream& in) { - auto_ptr arc(m_factory->NewStream(in)); - auto_ptr entry(arc->GetNextEntry()); + wxScopedPtr arc(m_factory->NewStream(in)); + wxScopedPtr entry(arc->GetNextEntry()); while (entry.get() != NULL) { char buf[1024]; @@ -1250,8 +1250,7 @@ void CorruptionTestCase::ExtractArchive(wxInputStream& in) while (arc->IsOk()) arc->Read(buf, sizeof(buf)); - auto_ptr next(arc->GetNextEntry()); - entry = next; + entry.reset(arc->GetNextEntry()); } }