From f41f9f61150eea670aa9a0351a310ff41e94c0a6 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Fri, 30 Mar 2018 12:54:48 +0200 Subject: [PATCH 2/2] Avoid auto_ptr in bundled boost [ mikhailnov@ROSA: changed "#if defined(BOOST_NO_CXX11_SMART_PTR)" to "#if __cplusplus < 201703L" ] Source: https://github.com/dealii/dealii/pull/6126/commits/92b86577ed847ce8dd3eaf7820bda86bdd925e73 This patch is not mandantory as GNU libstdc++ is backwards compatible by default, and LLVM libc++ can be forced to be compatible with std::auto_ptr: https://libcxx.llvm.org/docs/UsingLibcxx.html#c-17-specific-configuration-macros Signed-off-by: Mikhail Novosyolov --- boost/date_time/gregorian/greg_facet.hpp | 8 ++++++++ boost/detail/lightweight_thread.hpp | 12 ++++++++++++ boost/graph/detail/adjacency_list.hpp | 4 ++++ boost/iostreams/chain.hpp | 5 +++++ boost/random/uniform_on_sphere.hpp | 8 ++++++-- .../home/classic/core/non_terminal/impl/grammar.ipp | 5 +++++ boost/spirit/home/classic/symbols/impl/tst.ipp | 8 ++++++++ .../spirit/home/support/detail/lexer/generator.hpp | 13 +++++++++++++ 8 files changed, 61 insertions(+), 2 deletions(-) diff --git a/boost/date_time/gregorian/greg_facet.hpp b/boost/date_time/gregorian/greg_facet.hpp index b8c6d57f..2343cb95 100644 --- a/boost/date_time/gregorian/greg_facet.hpp +++ b/boost/date_time/gregorian/greg_facet.hpp @@ -290,7 +290,11 @@ namespace gregorian { * names as a default. */ catch(std::bad_cast&){ charT a = '\0'; +#if __cplusplus < 201703L std::auto_ptr< const facet_def > f(create_facet_def(a)); +#else + std::unique_ptr< const facet_def > f(create_facet_def(a)); +#endif num = date_time::find_match(f->get_short_month_names(), f->get_long_month_names(), (greg_month::max)(), s); // greg_month spans 1..12, so max returns the array size, @@ -332,7 +336,11 @@ namespace gregorian { * names as a default. */ catch(std::bad_cast&){ charT a = '\0'; +#if __cplusplus < 201703L std::auto_ptr< const facet_def > f(create_facet_def(a)); +#else + std::unique_ptr< const facet_def > f(create_facet_def(a)); +#endif num = date_time::find_match(f->get_short_weekday_names(), f->get_long_weekday_names(), (greg_weekday::max)() + 1, s); // greg_weekday spans 0..6, so increment is needed diff --git a/boost/detail/lightweight_thread.hpp b/boost/detail/lightweight_thread.hpp index 6fe70a61..f46568c1 100644 --- a/boost/detail/lightweight_thread.hpp +++ b/boost/detail/lightweight_thread.hpp @@ -77,7 +77,11 @@ public: extern "C" void * lw_thread_routine( void * pv ) { +#if __cplusplus < 201703L std::auto_ptr pt( static_cast( pv ) ); +#else + std::unique_ptr pt( static_cast( pv ) ); +#endif pt->run(); @@ -88,7 +92,11 @@ extern "C" void * lw_thread_routine( void * pv ) unsigned __stdcall lw_thread_routine( void * pv ) { +#if __cplusplus < 201703L std::auto_ptr pt( static_cast( pv ) ); +#else + std::unique_ptr pt( static_cast( pv ) ); +#endif pt->run(); @@ -117,7 +125,11 @@ private: template int lw_thread_create( pthread_t & pt, F f ) { +#if __cplusplus < 201703L 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() ); diff --git a/boost/graph/detail/adjacency_list.hpp b/boost/graph/detail/adjacency_list.hpp index 1145d88d..8a33c411 100644 --- a/boost/graph/detail/adjacency_list.hpp +++ b/boost/graph/detail/adjacency_list.hpp @@ -283,7 +283,11 @@ namespace boost { // invalidation for add_edge() with EdgeList=vecS. Instead we // hold a pointer to the property. std::auto_ptr is not // a perfect fit for the job, but it is darn close. +#if __cplusplus < 201703L std::auto_ptr m_property; +#else + std::unique_ptr m_property; +#endif }; #else template diff --git a/boost/iostreams/chain.hpp b/boost/iostreams/chain.hpp index 4af8cc98..8d9edeea 100644 --- a/boost/iostreams/chain.hpp +++ b/boost/iostreams/chain.hpp @@ -253,8 +253,13 @@ private: pback_size != -1 ? pback_size : pimpl_->pback_size_; +#if __cplusplus < 201703L std::auto_ptr buf(new streambuf_t(t, buffer_size, pback_size)); +#else + std::unique_ptr + buf(new streambuf_t(t, buffer_size, pback_size)); +#endif list().push_back(buf.get()); buf.release(); if (is_device::value) { diff --git a/boost/random/uniform_on_sphere.hpp b/boost/random/uniform_on_sphere.hpp index d5037352..cad1a777 100644 --- a/boost/random/uniform_on_sphere.hpp +++ b/boost/random/uniform_on_sphere.hpp @@ -225,8 +225,12 @@ public: } } while(sqsum == 0); // for all i: result[i] /= sqrt(sqsum) - std::transform(_container.begin(), _container.end(), _container.begin(), - std::bind2nd(std::multiplies(), 1/sqrt(sqsum))); + RealType inverse_distance = 1 / sqrt(sqsum); + for(typename Cont::iterator it = _container.begin(); + it != _container.end(); + ++it) { + *it *= inverse_distance; + } } } return _container; diff --git a/boost/spirit/home/classic/core/non_terminal/impl/grammar.ipp b/boost/spirit/home/classic/core/non_terminal/impl/grammar.ipp index cdb01862..33991c57 100644 --- a/boost/spirit/home/classic/core/non_terminal/impl/grammar.ipp +++ b/boost/spirit/home/classic/core/non_terminal/impl/grammar.ipp @@ -156,8 +156,13 @@ struct grammar_definition if (definitions[id]!=0) return *definitions[id]; +#if __cplusplus < 201703L std::auto_ptr result(new definition_t(target_grammar->derived())); +#else + std::unique_ptr + result(new definition_t(target_grammar->derived())); +#endif #ifdef BOOST_SPIRIT_THREADSAFE boost::unique_lock lock(helpers.mutex()); diff --git a/boost/spirit/home/classic/symbols/impl/tst.ipp b/boost/spirit/home/classic/symbols/impl/tst.ipp index 1a4a0c10..6e68e4b9 100644 --- a/boost/spirit/home/classic/symbols/impl/tst.ipp +++ b/boost/spirit/home/classic/symbols/impl/tst.ipp @@ -62,7 +62,11 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN tst_node* clone() const { +#if __cplusplus < 201703L std::auto_ptr copy(new tst_node(value)); +#else + std::unique_ptr copy(new tst_node(value)); +#endif if (left) copy->left = left->clone(); @@ -75,7 +79,11 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN } else { +#if __cplusplus < 201703L std::auto_ptr mid_data(new T(*middle.data)); +#else + std::unique_ptr mid_data(new T(*middle.data)); +#endif copy->middle.data = mid_data.release(); } diff --git a/boost/spirit/home/support/detail/lexer/generator.hpp b/boost/spirit/home/support/detail/lexer/generator.hpp index daa06e79..347aa203 100644 --- a/boost/spirit/home/support/detail/lexer/generator.hpp +++ b/boost/spirit/home/support/detail/lexer/generator.hpp @@ -116,10 +116,18 @@ public: protected: typedef detail::basic_charset charset; typedef detail::ptr_list charset_list; +#if __cplusplus < 201703L typedef std::auto_ptr charset_ptr; +#else + typedef std::unique_ptr charset_ptr; +#endif typedef detail::equivset equivset; typedef detail::ptr_list equivset_list; +#if __cplusplus < 201703L typedef std::auto_ptr equivset_ptr; +#else + typedef std::unique_ptr equivset_ptr; +#endif typedef typename charset::index_set index_set; typedef std::vector index_set_vector; typedef detail::basic_parser parser; @@ -377,8 +385,13 @@ protected: if (followpos_->empty ()) return npos; std::size_t index_ = 0; +#if __cplusplus < 201703L std::auto_ptr set_ptr_ (new node_set); std::auto_ptr vector_ptr_ (new node_vector); +#else + std::unique_ptr set_ptr_ (new node_set); + std::unique_ptr vector_ptr_ (new node_vector); +#endif for (typename detail::node::node_vector::const_iterator iter_ = followpos_->begin (), end_ = followpos_->end (); -- 2.20.1