From 57ecfeb2c26331c4616f8a47228b30adc39dc8cb Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 16 Sep 2018 05:58:29 +0300 Subject: [PATCH] Use map::insert instead of map::emplace, which doesn't work on g++ pre-6 (and msvc-10.0) --- include/boost/system/detail/config.hpp | 5 ----- .../system/detail/std_interoperability.hpp | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/include/boost/system/detail/config.hpp b/include/boost/system/detail/config.hpp index 1ff28f4..a9e6c72 100644 --- a/include/boost/system/detail/config.hpp +++ b/include/boost/system/detail/config.hpp @@ -16,11 +16,6 @@ # define BOOST_SYSTEM_HAS_SYSTEM_ERROR #endif -#if defined(BOOST_MSVC) && BOOST_MSVC < 1700 -// msvc-10.0 has no two-argument map::emplace -# undef BOOST_SYSTEM_HAS_SYSTEM_ERROR -#endif - // BOOST_SYSTEM_NOEXCEPT // Retained for backward compatibility only diff --git a/include/boost/system/detail/std_interoperability.hpp b/include/boost/system/detail/std_interoperability.hpp index 2db8f62..f38c98e 100644 --- a/include/boost/system/detail/std_interoperability.hpp +++ b/include/boost/system/detail/std_interoperability.hpp @@ -9,6 +9,7 @@ #include #include +#include // @@ -29,7 +30,7 @@ private: public: - std_category( boost::system::error_category const * pc ): pc_( pc ) + explicit std_category( boost::system::error_category const * pc ): pc_( pc ) { } @@ -54,13 +55,22 @@ public: inline std::error_category const & to_std_category( boost::system::error_category const & cat ) { - typedef std::map map_type; + typedef std::map< boost::system::error_category const *, std::unique_ptr > map_type; static map_type map_; - std::pair p = map_.emplace( &cat, &cat ); + map_type::iterator i = map_.find( &cat ); - return p.first->second; + if( i == map_.end() ) + { + std::unique_ptr p( new std_category( &cat ) ); + + std::pair r = map_.insert( map_type::value_type( &cat, std::move( p ) ) ); + + i = r.first; + } + + return *i->second; } inline bool std_category::equivalent( int code, const std::error_condition & condition ) const BOOST_NOEXCEPT