Ticket #7278: 7278.patch
File 7278.patch, 21.9 KB (added by , 10 years ago) |
---|
-
boost/asio/impl/error.ipp
31 31 class netdb_category : public boost::system::error_category 32 32 { 33 33 public: 34 const char* name() const 34 const char* name() const BOOST_SYSTEM_NOEXCEPT 35 35 { 36 36 return "asio.netdb"; 37 37 } … … 63 63 class addrinfo_category : public boost::system::error_category 64 64 { 65 65 public: 66 const char* name() const 66 const char* name() const BOOST_SYSTEM_NOEXCEPT 67 67 { 68 68 return "asio.addrinfo"; 69 69 } … … 93 93 class misc_category : public boost::system::error_category 94 94 { 95 95 public: 96 const char* name() const 96 const char* name() const BOOST_SYSTEM_NOEXCEPT 97 97 { 98 98 return "asio.misc"; 99 99 } -
boost/thread/future.hpp
113 113 { 114 114 inline 115 115 error_code 116 make_error_code(future_errc e) //BOOST_NOEXCEPT116 make_error_code(future_errc e) BOOST_SYSTEM_NOEXCEPT 117 117 { 118 118 return error_code(underlying_cast<int>(e), boost::future_category()); 119 119 } 120 120 121 121 inline 122 122 error_condition 123 make_error_condition(future_errc e) //BOOST_NOEXCEPT123 make_error_condition(future_errc e) BOOST_SYSTEM_NOEXCEPT 124 124 { 125 125 return error_condition(underlying_cast<int>(e), future_category()); 126 126 } -
libs/thread/src/future.cpp
19 19 public boost::system::error_category 20 20 { 21 21 public: 22 virtual const char* name() const ; //BOOST_NOEXCEPT;22 virtual const char* name() const BOOST_SYSTEM_NOEXCEPT; 23 23 virtual std::string message(int ev) const; 24 24 }; 25 25 26 26 const char* 27 future_error_category::name() const //BOOST_NOEXCEPT27 future_error_category::name() const BOOST_SYSTEM_NOEXCEPT 28 28 { 29 29 return "future"; 30 30 } -
libs/filesystem/src/codecvt_error_category.cpp
35 35 { 36 36 public: 37 37 codecvt_error_cat(){} 38 const char* name() const ;38 const char* name() const BOOST_SYSTEM_NOEXCEPT; 39 39 std::string message(int ev) const; 40 40 }; 41 41 42 const char* codecvt_error_cat::name() const 42 const char* codecvt_error_cat::name() const BOOST_SYSTEM_NOEXCEPT 43 43 { 44 44 return "codecvt"; 45 45 } -
boost/system/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 } -
boost/system/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 … … 31 31 32 32 #include <boost/config/abi_prefix.hpp> // must be the last #include 33 33 34 #ifndef BOOST_SYSTEM_NOEXCEPT 35 #define BOOST_SYSTEM_NOEXCEPT BOOST_NOEXCEPT 36 #endif 37 34 38 namespace boost 35 39 { 36 40 namespace system … … 184 188 public: 185 189 virtual ~error_category(){} 186 190 187 virtual const char * name() const = 0;191 virtual const char * name() const BOOST_SYSTEM_NOEXCEPT = 0; 188 192 virtual std::string message( int ev ) const = 0; 189 virtual error_condition default_error_condition( int ev ) const;190 virtual bool equivalent( int code,191 const error_condition & condition ) const ;192 virtual bool equivalent( const error_code & code,193 int condition ) const ;193 inline virtual error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT; 194 inline virtual bool equivalent( int code, 195 const error_condition & condition ) const BOOST_SYSTEM_NOEXCEPT; 196 inline virtual bool equivalent( const error_code & code, 197 int condition ) const BOOST_SYSTEM_NOEXCEPT; 194 198 195 bool operator==(const error_category & rhs) const { return this == &rhs; }196 bool operator!=(const error_category & rhs) const { return this != &rhs; }197 bool operator<( const error_category & rhs ) const 199 bool operator==(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT { return this == &rhs; } 200 bool operator!=(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT { return this != &rhs; } 201 bool operator<( const error_category & rhs ) const BOOST_SYSTEM_NOEXCEPT 198 202 { 199 203 return std::less<const error_category*>()( this, &rhs ); 200 204 } … … 202 206 203 207 // predefined error categories -----------------------------------------// 204 208 205 BOOST_SYSTEM_DECL const error_category & system_category(); 206 BOOST_SYSTEM_DECL const error_category & generic_category(); 207 209 # ifdef BOOST_ERROR_CODE_HEADER_ONLY 210 inline const error_category & system_category() BOOST_SYSTEM_NOEXCEPT; 211 inline const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT; 212 #else 213 BOOST_SYSTEM_DECL const error_category & system_category() BOOST_SYSTEM_NOEXCEPT; 214 BOOST_SYSTEM_DECL const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT; 215 #endif 208 216 // deprecated synonyms --------------------------------------------------// 209 217 210 218 # ifndef BOOST_SYSTEM_NO_DEPRECATED … … 225 233 public: 226 234 227 235 // constructors: 228 error_condition() : m_val(0), m_cat(&generic_category()) {}229 error_condition( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {}236 error_condition() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&generic_category()) {} 237 error_condition( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT : m_val(val), m_cat(&cat) {} 230 238 231 239 template <class ErrorConditionEnum> 232 240 error_condition(ErrorConditionEnum e, 233 typename boost::enable_if<is_error_condition_enum<ErrorConditionEnum> >::type* = 0) 241 typename boost::enable_if<is_error_condition_enum<ErrorConditionEnum> >::type* = 0) BOOST_SYSTEM_NOEXCEPT 234 242 { 235 243 *this = make_error_condition(e); 236 244 } 237 245 238 246 // modifiers: 239 247 240 void assign( int val, const error_category & cat ) 241 { 248 void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT 249 { 242 250 m_val = val; 243 251 m_cat = &cat; 244 252 } 245 253 246 254 template<typename ErrorConditionEnum> 247 255 typename boost::enable_if<is_error_condition_enum<ErrorConditionEnum>, error_condition>::type & 248 operator=( ErrorConditionEnum val ) 249 { 256 operator=( ErrorConditionEnum val ) BOOST_SYSTEM_NOEXCEPT 257 { 250 258 *this = make_error_condition(val); 251 259 return *this; 252 260 } 253 261 254 void clear() 262 void clear() BOOST_SYSTEM_NOEXCEPT 255 263 { 256 264 m_val = 0; 257 265 m_cat = &generic_category(); 258 266 } 259 267 260 268 // observers: 261 int value() const { return m_val; }262 const error_category & category() const { return *m_cat; }269 int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; } 270 const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; } 263 271 std::string message() const { return m_cat->message(value()); } 264 272 265 273 typedef void (*unspecified_bool_type)(); 266 274 static void unspecified_bool_true() {} 267 275 268 operator unspecified_bool_type() const // true if error269 { 276 operator unspecified_bool_type() const BOOST_SYSTEM_NOEXCEPT // true if error 277 { 270 278 return m_val == 0 ? 0 : unspecified_bool_true; 271 279 } 272 280 273 bool operator!() const // true if no error281 bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error 274 282 { 275 283 return m_val == 0; 276 284 } … … 279 287 // the more symmetrical non-member syntax allows enum 280 288 // conversions work for both rhs and lhs. 281 289 inline friend bool operator==( const error_condition & lhs, 282 const error_condition & rhs ) 290 const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT 283 291 { 284 292 return lhs.m_cat == rhs.m_cat && lhs.m_val == rhs.m_val; 285 } 293 } 286 294 287 295 inline friend bool operator<( const error_condition & lhs, 288 const error_condition & rhs ) 296 const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT 289 297 // the more symmetrical non-member syntax allows enum 290 298 // conversions work for both rhs and lhs. 291 299 { … … 312 320 public: 313 321 314 322 // constructors: 315 error_code() : m_val(0), m_cat(&system_category()) {}316 error_code( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {}323 error_code() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&system_category()) {} 324 error_code( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT : m_val(val), m_cat(&cat) {} 317 325 318 326 template <class ErrorCodeEnum> 319 327 error_code(ErrorCodeEnum e, 320 typename boost::enable_if<is_error_code_enum<ErrorCodeEnum> >::type* = 0) 328 typename boost::enable_if<is_error_code_enum<ErrorCodeEnum> >::type* = 0) BOOST_SYSTEM_NOEXCEPT 321 329 { 322 330 *this = make_error_code(e); 323 331 } 324 332 325 333 // modifiers: 326 void assign( int val, const error_category & cat ) 327 { 334 void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT 335 { 328 336 m_val = val; 329 337 m_cat = &cat; 330 338 } 331 339 332 340 template<typename ErrorCodeEnum> 333 341 typename boost::enable_if<is_error_code_enum<ErrorCodeEnum>, error_code>::type & 334 operator=( ErrorCodeEnum val ) 335 { 342 operator=( ErrorCodeEnum val ) BOOST_SYSTEM_NOEXCEPT 343 { 336 344 *this = make_error_code(val); 337 345 return *this; 338 346 } 339 347 340 void clear() 348 void clear() BOOST_SYSTEM_NOEXCEPT 341 349 { 342 350 m_val = 0; 343 351 m_cat = &system_category(); 344 352 } 345 353 346 354 // observers: 347 int value() const { return m_val; }348 const error_category & category() const { return *m_cat; }349 error_condition default_error_condition() const { return m_cat->default_error_condition(value()); }355 int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; } 356 const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; } 357 error_condition default_error_condition() const BOOST_SYSTEM_NOEXCEPT { return m_cat->default_error_condition(value()); } 350 358 std::string message() const { return m_cat->message(value()); } 351 359 352 360 typedef void (*unspecified_bool_type)(); 353 361 static void unspecified_bool_true() {} 354 362 355 operator unspecified_bool_type() const // true if error356 { 363 operator unspecified_bool_type() const BOOST_SYSTEM_NOEXCEPT // true if error 364 { 357 365 return m_val == 0 ? 0 : unspecified_bool_true; 358 366 } 359 367 360 bool operator!() const // true if no error368 bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error 361 369 { 362 370 return m_val == 0; 363 371 } 364 372 365 373 // relationals: 366 374 inline friend bool operator==( const error_code & lhs, 367 const error_code & rhs ) 375 const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT 368 376 // the more symmetrical non-member syntax allows enum 369 377 // conversions work for both rhs and lhs. 370 378 { … … 372 380 } 373 381 374 382 inline friend bool operator<( const error_code & lhs, 375 const error_code & rhs ) 383 const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT 376 384 // the more symmetrical non-member syntax allows enum 377 385 // conversions work for both rhs and lhs. 378 386 { 379 387 return lhs.m_cat < rhs.m_cat 380 388 || (lhs.m_cat == rhs.m_cat && lhs.m_val < rhs.m_val); 381 389 } 382 390 383 391 private: 384 392 int m_val; 385 393 const error_category * m_cat; … … 426 434 } 427 435 428 436 inline bool operator==( const error_code & code, 429 const error_condition & condition ) 437 const error_condition & condition ) BOOST_SYSTEM_NOEXCEPT 430 438 { 431 439 return code.category().equivalent( code.value(), condition ) 432 440 || condition.category().equivalent( code, condition.value() ); 433 441 } 434 442 435 443 inline bool operator!=( const error_code & lhs, 436 const error_condition & rhs ) 444 const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT 437 445 { 438 446 return !(lhs == rhs); 439 447 } 440 448 441 449 inline bool operator==( const error_condition & condition, 442 const error_code & code ) 450 const error_code & code ) BOOST_SYSTEM_NOEXCEPT 443 451 { 444 452 return condition.category().equivalent( code, condition.value() ) 445 453 || code.category().equivalent( code.value(), condition ); 446 454 } 447 455 448 456 inline bool operator!=( const error_condition & lhs, 449 const error_code & rhs ) 457 const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT 450 458 { 451 459 return !(lhs == rhs); 452 460 } 453 461 454 462 // TODO: both of these may move elsewhere, but the LWG hasn't spoken yet. 455 463 456 464 template <class charT, class traits> … … 482 490 483 491 // error_category default implementation -------------------------------// 484 492 485 inline error_condition error_category::default_error_condition( int ev ) const486 { 493 error_condition error_category::default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT 494 { 487 495 return error_condition( ev, *this ); 488 496 } 489 497 490 inlinebool error_category::equivalent( int code,491 const error_condition & condition ) const 498 bool error_category::equivalent( int code, 499 const error_condition & condition ) const BOOST_SYSTEM_NOEXCEPT 492 500 { 493 501 return default_error_condition( code ) == condition; 494 502 } 495 503 496 inlinebool error_category::equivalent( const error_code & code,497 int condition ) const 504 bool error_category::equivalent( const error_code & code, 505 int condition ) const BOOST_SYSTEM_NOEXCEPT 498 506 { 499 507 return *this == code.category() && code.value() == condition; 500 508 } -
libs/system/test/error_code_user_test.cpp
75 75 namespace lib3 76 76 { 77 77 // lib3 has its own error_category: 78 const boost::system::error_category & get_lib3_error_category() ;78 const boost::system::error_category & get_lib3_error_category() BOOST_SYSTEM_NOEXCEPT; 79 79 const boost::system::error_category & lib3_error_category = get_lib3_error_category(); 80 80 81 81 enum error … … 112 112 public: 113 113 lib3_error_category_imp() : boost::system::error_category() { } 114 114 115 const char * name() const 115 const char * name() const BOOST_SYSTEM_NOEXCEPT 116 116 { 117 117 return "lib3"; 118 118 } 119 119 120 boost::system::error_condition default_error_condition( int ev ) const 120 boost::system::error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT 121 121 { 122 122 return ev == boo_boo 123 123 ? boost::system::error_condition( boost::system::errc::io_error, … … 135 135 136 136 }; 137 137 138 const boost::system::error_category & get_lib3_error_category() 138 const boost::system::error_category & get_lib3_error_category() BOOST_SYSTEM_NOEXCEPT 139 139 { 140 140 static const lib3_error_category_imp l3ecat; 141 141 return l3ecat; … … 156 156 namespace lib4 157 157 { 158 158 // lib4 has its own error_category: 159 const boost::system::error_category & get_lib4_error_category() ;159 const boost::system::error_category & get_lib4_error_category() BOOST_SYSTEM_NOEXCEPT; 160 160 const boost::system::error_category & lib4_error_category = get_lib4_error_category(); 161 161 162 162 extern const boost::system::error_code boo_boo; … … 174 174 public: 175 175 lib4_error_category_imp() : boost::system::error_category() { } 176 176 177 const char * name() const 177 const char * name() const BOOST_SYSTEM_NOEXCEPT 178 178 { 179 179 return "lib4"; 180 180 } 181 181 182 boost::system::error_condition default_error_condition( int ev ) const 182 boost::system::error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT 183 183 { 184 184 return ev == boo_boo.value() 185 185 ? boost::system::error_condition( boost::system::errc::io_error, … … 195 195 } 196 196 }; 197 197 198 const boost::system::error_category & get_lib4_error_category() 198 const boost::system::error_category & get_lib4_error_category() BOOST_SYSTEM_NOEXCEPT 199 199 { 200 200 static const lib4_error_category_imp l4ecat; 201 201 return l4ecat; -
libs/system/src/error_code.cpp
22 22 #include <cstdlib> 23 23 #include <cassert> 24 24 25 using namespace boost::system;26 using namespace boost::system::errc;27 28 25 #include <cstring> // for strerror/strerror_r 29 26 30 27 # if defined( BOOST_WINDOWS_API ) … … 36 33 # endif 37 34 38 35 //----------------------------------------------------------------------------// 36 namespace boost 37 { 38 namespace system 39 { 39 40 40 41 namespace 41 42 { 42 #if defined(__PGI) 43 using boost::system::errc::invalid_argument; 44 #endif 43 45 44 // standard error categories ---------------------------------------------// 46 45 47 46 class generic_error_category : public error_category 48 47 { 49 48 public: 50 49 generic_error_category(){} 51 const char * name() const ;50 const char * name() const BOOST_SYSTEM_NOEXCEPT; 52 51 std::string message( int ev ) const; 53 52 }; 54 53 … … 56 55 { 57 56 public: 58 57 system_error_category(){} 59 const char * name() const ;58 const char * name() const BOOST_SYSTEM_NOEXCEPT; 60 59 std::string message( int ev ) const; 61 error_condition default_error_condition( int ev ) const ;60 error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT; 62 61 }; 63 62 64 63 // generic_error_category implementation ---------------------------------// 65 64 66 const char * generic_error_category::name() const 65 const char * generic_error_category::name() const BOOST_SYSTEM_NOEXCEPT 67 66 { 68 67 return "generic"; 69 68 } 70 69 71 70 std::string generic_error_category::message( int ev ) const 72 71 { 72 using namespace boost::system::errc; 73 #if defined(__PGI) 74 using boost::system::errc::invalid_argument; 75 #endif 76 73 77 static std::string unknown_err( "Unknown error" ); 74 78 // strerror_r is preferred because it is always thread safe, 75 79 // however, we fallback to strerror in certain cases because: … … 133 137 } 134 138 } 135 139 std::string msg; 140 # ifndef BOOST_NO_EXCEPTIONS 136 141 try 142 # endif 137 143 { 138 144 msg = ( ( result == invalid_argument ) ? "Unknown error" : bp ); 139 145 } … … 154 160 } 155 161 // system_error_category implementation --------------------------------// 156 162 157 const char * system_error_category::name() const 163 const char * system_error_category::name() const BOOST_SYSTEM_NOEXCEPT 158 164 { 159 165 return "system"; 160 166 } 161 167 162 error_condition system_error_category::default_error_condition( int ev ) const 168 error_condition system_error_category::default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT 163 169 { 170 using namespace boost::system::errc; 171 #if defined(__PGI) 172 using boost::system::errc::invalid_argument; 173 #endif 174 164 175 switch ( ev ) 165 176 { 166 177 case 0: return make_error_condition( success ); … … 401 412 402 413 } // unnamed namespace 403 414 404 namespace boost405 {406 namespace system407 {408 415 409 416 # ifndef BOOST_SYSTEM_NO_DEPRECATED 410 417 BOOST_SYSTEM_DECL error_code throws; // "throw on error" special error_code; … … 414 421 // address for comparison purposes 415 422 # endif 416 423 417 BOOST_SYSTEM_DECL const error_category & system_category() 424 BOOST_SYSTEM_DECL const error_category & system_category() BOOST_SYSTEM_NOEXCEPT 418 425 { 419 426 static const system_error_category system_category_const; 420 427 return system_category_const; 421 428 } 422 429 423 BOOST_SYSTEM_DECL const error_category & generic_category() 430 BOOST_SYSTEM_DECL const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT 424 431 { 425 432 static const generic_error_category generic_category_const; 426 433 return generic_category_const;