Maintain the same error_category class layout in 03/11 mode

This commit is contained in:
Peter Dimov
2017-07-24 05:32:44 +03:00
parent d7ef760af7
commit c639237adf

View File

@ -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: