Ticket #7475: 7475.patch
File 7475.patch, 6.4 KB (added by , 10 years ago) |
---|
-
system_error.hpp
21 21 22 22 class BOOST_SYMBOL_VISIBLE system_error : public std::runtime_error 23 23 // BOOST_SYMBOL_VISIBLE is needed by GCC to ensure system_error thrown from a shared 24 // library can be caught. See svn.boost.org/trac/boost/ticket/3697 24 // library can be caught. See svn.boost.org/trac/boost/ticket/3697 25 25 { 26 26 public: 27 27 system_error( error_code ec ) … … 61 61 { 62 62 if ( m_what.empty() ) 63 63 { 64 #ifndef BOOST_NO_EXCEPTIONS 64 65 try 66 #endif 65 67 { 66 68 m_what = this->std::runtime_error::what(); 67 69 if ( !m_what.empty() ) m_what += ": "; 68 70 m_what += m_error_code.message(); 69 71 } 72 #ifndef BOOST_NO_EXCEPTIONS 70 73 catch (...) { return std::runtime_error::what(); } 74 #endif 71 75 } 72 76 return m_what.c_str(); 73 77 } -
error_code.hpp
23 23 #include <functional> 24 24 25 25 // TODO: undef these macros if not already defined 26 #include <boost/cerrno.hpp> 26 #include <boost/cerrno.hpp> 27 27 28 28 #if !defined(BOOST_POSIX_API) && !defined(BOOST_WINDOWS_API) 29 29 # error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined … … 186 186 187 187 virtual const char * name() const = 0; 188 188 virtual std::string message( int ev ) const = 0; 189 virtual error_condition default_error_condition( int ev ) const;190 virtual bool equivalent( int code,189 inline virtual error_condition default_error_condition( int ev ) const; 190 inline virtual bool equivalent( int code, 191 191 const error_condition & condition ) const; 192 virtual bool equivalent( const error_code & code,192 inline virtual bool equivalent( const error_code & code, 193 193 int condition ) const; 194 194 195 195 bool operator==(const error_category & rhs) const { return this == &rhs; } … … 202 202 203 203 // predefined error categories -----------------------------------------// 204 204 205 # ifdef BOOST_ERROR_CODE_HEADER_ONLY 206 inline const error_category & system_category(); 207 inline const error_category & generic_category(); 208 #else 205 209 BOOST_SYSTEM_DECL const error_category & system_category(); 206 210 BOOST_SYSTEM_DECL const error_category & generic_category(); 207 211 #endif 208 212 // deprecated synonyms --------------------------------------------------// 209 213 210 214 # ifndef BOOST_SYSTEM_NO_DEPRECATED … … 238 242 // modifiers: 239 243 240 244 void assign( int val, const error_category & cat ) 241 { 245 { 242 246 m_val = val; 243 247 m_cat = &cat; 244 248 } 245 249 246 250 template<typename ErrorConditionEnum> 247 251 typename boost::enable_if<is_error_condition_enum<ErrorConditionEnum>, error_condition>::type & 248 252 operator=( ErrorConditionEnum val ) 249 { 253 { 250 254 *this = make_error_condition(val); 251 255 return *this; 252 256 } … … 266 270 static void unspecified_bool_true() {} 267 271 268 272 operator unspecified_bool_type() const // true if error 269 { 273 { 270 274 return m_val == 0 ? 0 : unspecified_bool_true; 271 275 } 272 276 … … 282 286 const error_condition & rhs ) 283 287 { 284 288 return lhs.m_cat == rhs.m_cat && lhs.m_val == rhs.m_val; 285 } 289 } 286 290 287 291 inline friend bool operator<( const error_condition & lhs, 288 292 const error_condition & rhs ) … … 324 328 325 329 // modifiers: 326 330 void assign( int val, const error_category & cat ) 327 { 331 { 328 332 m_val = val; 329 333 m_cat = &cat; 330 334 } 331 335 332 336 template<typename ErrorCodeEnum> 333 337 typename boost::enable_if<is_error_code_enum<ErrorCodeEnum>, error_code>::type & 334 338 operator=( ErrorCodeEnum val ) 335 { 339 { 336 340 *this = make_error_code(val); 337 341 return *this; 338 342 } … … 353 357 static void unspecified_bool_true() {} 354 358 355 359 operator unspecified_bool_type() const // true if error 356 { 360 { 357 361 return m_val == 0 ? 0 : unspecified_bool_true; 358 362 } 359 363 … … 379 383 return lhs.m_cat < rhs.m_cat 380 384 || (lhs.m_cat == rhs.m_cat && lhs.m_val < rhs.m_val); 381 385 } 382 386 383 387 private: 384 388 int m_val; 385 389 const error_category * m_cat; … … 431 435 return code.category().equivalent( code.value(), condition ) 432 436 || condition.category().equivalent( code, condition.value() ); 433 437 } 434 438 435 439 inline bool operator!=( const error_code & lhs, 436 440 const error_condition & rhs ) 437 441 { 438 442 return !(lhs == rhs); 439 443 } 440 444 441 445 inline bool operator==( const error_condition & condition, 442 446 const error_code & code ) 443 447 { 444 448 return condition.category().equivalent( code, condition.value() ) 445 449 || code.category().equivalent( code.value(), condition ); 446 450 } 447 451 448 452 inline bool operator!=( const error_condition & lhs, 449 453 const error_code & rhs ) 450 454 { 451 455 return !(lhs == rhs); 452 456 } 453 457 454 458 // TODO: both of these may move elsewhere, but the LWG hasn't spoken yet. 455 459 456 460 template <class charT, class traits> … … 482 486 483 487 // error_category default implementation -------------------------------// 484 488 485 inlineerror_condition error_category::default_error_condition( int ev ) const486 { 489 error_condition error_category::default_error_condition( int ev ) const 490 { 487 491 return error_condition( ev, *this ); 488 492 } 489 493 490 inlinebool error_category::equivalent( int code,494 bool error_category::equivalent( int code, 491 495 const error_condition & condition ) const 492 496 { 493 497 return default_error_condition( code ) == condition; 494 498 } 495 499 496 inlinebool error_category::equivalent( const error_code & code,500 bool error_category::equivalent( const error_code & code, 497 501 int condition ) const 498 502 { 499 503 return *this == code.category() && code.value() == condition;