From 15ad7002a57a6f3edaebe38b533ebf7005c7608a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Wed, 7 Jan 2015 16:14:33 +0100 Subject: [PATCH] Trying to fix warning "variable 'pnothrow' is not needed and will not be emitted" --- include/boost/move/make_unique.hpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/include/boost/move/make_unique.hpp b/include/boost/move/make_unique.hpp index 8dc491b..e86a992 100644 --- a/include/boost/move/make_unique.hpp +++ b/include/boost/move/make_unique.hpp @@ -64,7 +64,14 @@ struct unique_ptr_if typedef void t_is_array_of_known_bound; }; -static std::nothrow_t *pnothrow; +template +struct nothrow_holder +{ + static std::nothrow_t *pnothrow; +}; + +template +std::nothrow_t *nothrow_holder::pnothrow; } //namespace move_upmu { } //namespace boost{ @@ -92,7 +99,7 @@ template inline BOOST_MOVE_DOC1ST(unique_ptr, typename ::boost::move_upmu::unique_ptr_if::t_is_not_array) make_unique_nothrow(BOOST_FWD_REF(Args)... args) -{ return unique_ptr(new (*boost::move_upmu::pnothrow)T(::boost::forward(args)...)); } +{ return unique_ptr(new (*boost::move_upmu::nothrow_holder<>::pnothrow)T(::boost::forward(args)...)); } #else #define BOOST_MOVE_MAKE_UNIQUE_CODE(N)\ @@ -104,7 +111,7 @@ inline BOOST_MOVE_DOC1ST(unique_ptr, template\ typename ::boost::move_upmu::unique_ptr_if::t_is_not_array\ make_unique_nothrow( BOOST_MOVE_UREF##N)\ - { return unique_ptr( new (*boost::move_upmu::pnothrow)T ( BOOST_MOVE_FWD##N ) ); }\ + { return unique_ptr( new (*boost::move_upmu::nothrow_holder<>::pnothrow)T ( BOOST_MOVE_FWD##N ) ); }\ // BOOST_MOVE_ITERATE_0TO9(BOOST_MOVE_MAKE_UNIQUE_CODE) #undef BOOST_MOVE_MAKE_UNIQUE_CODE @@ -130,7 +137,7 @@ inline BOOST_MOVE_DOC1ST(unique_ptr, typename ::boost::move_upmu::unique_ptr_if::t_is_not_array) make_unique_nothrow_definit() { - return unique_ptr(new (*boost::move_upmu::pnothrow)T); + return unique_ptr(new (*boost::move_upmu::nothrow_holder<>::pnothrow)T); } //! Remarks: This function shall not participate in overload resolution unless T is an array of @@ -156,7 +163,7 @@ inline BOOST_MOVE_DOC1ST(unique_ptr, make_unique_nothrow(std::size_t n) { typedef typename ::boost::move_upmu::remove_extent::type U; - return unique_ptr(new (*boost::move_upmu::pnothrow)U[n]()); + return unique_ptr(new (*boost::move_upmu::nothrow_holder<>::pnothrow)U[n]()); } //! Remarks: This function shall not participate in overload resolution unless T is an array of @@ -182,7 +189,7 @@ inline BOOST_MOVE_DOC1ST(unique_ptr, make_unique_nothrow_definit(std::size_t n) { typedef typename ::boost::move_upmu::remove_extent::type U; - return unique_ptr(new (*boost::move_upmu::pnothrow) U[n]); + return unique_ptr(new (*boost::move_upmu::nothrow_holder<>::pnothrow) U[n]); } #if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)