From 4129bb6a5cfc7394c62c9e7550b5f48b261e9153 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 19 Feb 2018 06:16:11 +0200 Subject: [PATCH] Use unique_ptr instead of auto_ptr when available --- include/boost/detail/lightweight_thread.hpp | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/boost/detail/lightweight_thread.hpp b/include/boost/detail/lightweight_thread.hpp index 6fe70a6..2145815 100644 --- a/include/boost/detail/lightweight_thread.hpp +++ b/include/boost/detail/lightweight_thread.hpp @@ -77,8 +77,16 @@ public: extern "C" void * lw_thread_routine( void * pv ) { +#if defined(BOOST_NO_CXX11_SMART_PTR) + std::auto_ptr pt( static_cast( pv ) ); +#else + + std::unique_ptr pt( static_cast( pv ) ); + +#endif + pt->run(); return 0; @@ -88,8 +96,16 @@ extern "C" void * lw_thread_routine( void * pv ) unsigned __stdcall lw_thread_routine( void * pv ) { +#if defined(BOOST_NO_CXX11_SMART_PTR) + std::auto_ptr pt( static_cast( pv ) ); +#else + + std::unique_ptr pt( static_cast( pv ) ); + +#endif + pt->run(); return 0; @@ -117,8 +133,16 @@ private: template int lw_thread_create( pthread_t & pt, F f ) { +#if defined(BOOST_NO_CXX11_SMART_PTR) + std::auto_ptr p( new lw_thread_impl( f ) ); +#else + + std::unique_ptr p( new lw_thread_impl( f ) ); + +#endif + int r = pthread_create( &pt, 0, lw_thread_routine, p.get() ); if( r == 0 )