From c639237adf6be9f0f52aab5f35c257e4e4209d4c Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 24 Jul 2017 05:32:44 +0300 Subject: [PATCH] Maintain the same error_category class layout in 03/11 mode --- include/boost/system/error_code.hpp | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index 1ddb471..ec7e53a 100644 --- a/include/boost/system/error_code.hpp +++ b/include/boost/system/error_code.hpp @@ -262,6 +262,48 @@ namespace boost return std_cat_; } +#else + + // to maintain ABI compatibility between 03 and 11, + // define a class with the same layout + + private: + + class std_category + { + private: + + boost::system::error_category const * pc_; + + public: + + explicit std_category( boost::system::error_category const * pc ): pc_( pc ) + { + } + + virtual ~std_category() {} + + virtual const char * name() const BOOST_NOEXCEPT + { + return pc_->name(); + } + + virtual std::string message( int ev ) const + { + return pc_->message( ev ); + } + + // we can't define default_error_condition or equivalent, + // so if called, it will crash, but that's still better than the + // alternative + }; + + std_category std_cat_; + + public: + + error_category() BOOST_SYSTEM_NOEXCEPT: std_cat_( this ) {} + #endif public: