use std::unique_ptr instead of std::auto_ptr with C++11+ compilers to prevent std::auto_ptr deprecation warnings

This commit is contained in:
root 2016-10-14 11:49:45 +02:00
parent 12fc175b5a
commit 895c3dfcd5
5 changed files with 20 additions and 0 deletions

View File

@ -81,7 +81,11 @@ protected:
private: private:
TestMethod _test; TestMethod _test;
#if __cplusplus < 201103L
std::auto_ptr<Fixture> _fixture; std::auto_ptr<Fixture> _fixture;
#else
std::unique_ptr<Fixture> _fixture;
#endif
}; };

View File

@ -89,7 +89,11 @@ public:
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
#if __cplusplus < 201103L
std::auto_ptr<AbstractFactory> ptr(pAbstractFactory); std::auto_ptr<AbstractFactory> ptr(pAbstractFactory);
#else
std::unique_ptr<AbstractFactory> ptr(pAbstractFactory);
#endif
typename FactoryMap::iterator it = _map.find(className); typename FactoryMap::iterator it = _map.find(className);
if (it == _map.end()) if (it == _map.end())
_map[className] = ptr.release(); _map[className] = ptr.release();

View File

@ -59,7 +59,11 @@ void pad(std::string& str, int precision, int width, char prefix = ' ', char dec
std::string::size_type frac = str.length() - decSepPos - 1; std::string::size_type frac = str.length() - decSepPos - 1;
std::string::size_type ePos = str.find_first_of("eE"); std::string::size_type ePos = str.find_first_of("eE");
#if __cplusplus < 201103L
std::auto_ptr<std::string> eStr; std::auto_ptr<std::string> eStr;
#else
std::unique_ptr<std::string> eStr;
#endif
if (ePos != std::string::npos) if (ePos != std::string::npos)
{ {
eStr.reset(new std::string(str.substr(ePos, std::string::npos))); eStr.reset(new std::string(str.substr(ePos, std::string::npos)));

View File

@ -78,7 +78,11 @@ void HTTPServerConnection::run()
response.set("Server", server); response.set("Server", server);
try try
{ {
#if __cplusplus < 201103L
std::auto_ptr<HTTPRequestHandler> pHandler(_pFactory->createRequestHandler(request)); std::auto_ptr<HTTPRequestHandler> pHandler(_pFactory->createRequestHandler(request));
#else
std::unique_ptr<HTTPRequestHandler> pHandler(_pFactory->createRequestHandler(request));
#endif
if (pHandler.get()) if (pHandler.get())
{ {
if (request.expectContinue()) if (request.expectContinue())

View File

@ -110,7 +110,11 @@ void TCPServerDispatcher::run()
TCPConnectionNotification* pCNf = dynamic_cast<TCPConnectionNotification*>(pNf.get()); TCPConnectionNotification* pCNf = dynamic_cast<TCPConnectionNotification*>(pNf.get());
if (pCNf) if (pCNf)
{ {
#if __cplusplus < 201103L
std::auto_ptr<TCPServerConnection> pConnection(_pConnectionFactory->createConnection(pCNf->socket())); std::auto_ptr<TCPServerConnection> pConnection(_pConnectionFactory->createConnection(pCNf->socket()));
#else
std::unique_ptr<TCPServerConnection> pConnection(_pConnectionFactory->createConnection(pCNf->socket()));
#endif
poco_check_ptr(pConnection.get()); poco_check_ptr(pConnection.get());
beginConnection(); beginConnection();
pConnection->start(); pConnection->start();