annotate DEPENDENCIES/generic/include/boost/system/error_code.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 // boost/system/error_code.hpp ---------------------------------------------//
Chris@16 2
Chris@16 3 // Copyright Beman Dawes 2006, 2007
Chris@16 4 // Copyright Christoper Kohlhoff 2007
Chris@16 5
Chris@16 6 // Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 7 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8
Chris@16 9 // See library home page at http://www.boost.org/libs/system
Chris@16 10
Chris@16 11 #ifndef BOOST_ERROR_CODE_HPP
Chris@16 12 #define BOOST_ERROR_CODE_HPP
Chris@16 13
Chris@16 14 #include <boost/system/config.hpp>
Chris@16 15 #include <boost/cstdint.hpp>
Chris@16 16 #include <boost/assert.hpp>
Chris@16 17 #include <boost/noncopyable.hpp>
Chris@16 18 #include <boost/utility/enable_if.hpp>
Chris@16 19 #include <ostream>
Chris@16 20 #include <string>
Chris@16 21 #include <stdexcept>
Chris@16 22 #include <functional>
Chris@16 23
Chris@16 24 // TODO: undef these macros if not already defined
Chris@16 25 #include <boost/cerrno.hpp>
Chris@16 26
Chris@16 27 #if !defined(BOOST_POSIX_API) && !defined(BOOST_WINDOWS_API)
Chris@16 28 # error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined
Chris@16 29 #endif
Chris@16 30
Chris@16 31 #include <boost/config/abi_prefix.hpp> // must be the last #include
Chris@16 32
Chris@16 33 #ifndef BOOST_SYSTEM_NOEXCEPT
Chris@16 34 #define BOOST_SYSTEM_NOEXCEPT BOOST_NOEXCEPT
Chris@16 35 #endif
Chris@16 36
Chris@16 37 namespace boost
Chris@16 38 {
Chris@16 39 namespace system
Chris@16 40 {
Chris@16 41
Chris@16 42 class error_code;
Chris@16 43 class error_condition;
Chris@16 44
Chris@16 45 // "Concept" helpers ---------------------------------------------------//
Chris@16 46
Chris@16 47 template< class T >
Chris@16 48 struct is_error_code_enum { static const bool value = false; };
Chris@16 49
Chris@16 50 template< class T >
Chris@16 51 struct is_error_condition_enum { static const bool value = false; };
Chris@16 52
Chris@16 53 // generic error_conditions --------------------------------------------//
Chris@16 54
Chris@16 55 namespace errc
Chris@16 56 {
Chris@16 57 enum errc_t
Chris@16 58 {
Chris@16 59 success = 0,
Chris@16 60 address_family_not_supported = EAFNOSUPPORT,
Chris@16 61 address_in_use = EADDRINUSE,
Chris@16 62 address_not_available = EADDRNOTAVAIL,
Chris@16 63 already_connected = EISCONN,
Chris@16 64 argument_list_too_long = E2BIG,
Chris@16 65 argument_out_of_domain = EDOM,
Chris@16 66 bad_address = EFAULT,
Chris@16 67 bad_file_descriptor = EBADF,
Chris@16 68 bad_message = EBADMSG,
Chris@16 69 broken_pipe = EPIPE,
Chris@16 70 connection_aborted = ECONNABORTED,
Chris@16 71 connection_already_in_progress = EALREADY,
Chris@16 72 connection_refused = ECONNREFUSED,
Chris@16 73 connection_reset = ECONNRESET,
Chris@16 74 cross_device_link = EXDEV,
Chris@16 75 destination_address_required = EDESTADDRREQ,
Chris@16 76 device_or_resource_busy = EBUSY,
Chris@16 77 directory_not_empty = ENOTEMPTY,
Chris@16 78 executable_format_error = ENOEXEC,
Chris@16 79 file_exists = EEXIST,
Chris@16 80 file_too_large = EFBIG,
Chris@16 81 filename_too_long = ENAMETOOLONG,
Chris@16 82 function_not_supported = ENOSYS,
Chris@16 83 host_unreachable = EHOSTUNREACH,
Chris@16 84 identifier_removed = EIDRM,
Chris@16 85 illegal_byte_sequence = EILSEQ,
Chris@16 86 inappropriate_io_control_operation = ENOTTY,
Chris@16 87 interrupted = EINTR,
Chris@16 88 invalid_argument = EINVAL,
Chris@16 89 invalid_seek = ESPIPE,
Chris@16 90 io_error = EIO,
Chris@16 91 is_a_directory = EISDIR,
Chris@16 92 message_size = EMSGSIZE,
Chris@16 93 network_down = ENETDOWN,
Chris@16 94 network_reset = ENETRESET,
Chris@16 95 network_unreachable = ENETUNREACH,
Chris@16 96 no_buffer_space = ENOBUFS,
Chris@16 97 no_child_process = ECHILD,
Chris@16 98 no_link = ENOLINK,
Chris@16 99 no_lock_available = ENOLCK,
Chris@16 100 no_message_available = ENODATA,
Chris@16 101 no_message = ENOMSG,
Chris@16 102 no_protocol_option = ENOPROTOOPT,
Chris@16 103 no_space_on_device = ENOSPC,
Chris@16 104 no_stream_resources = ENOSR,
Chris@16 105 no_such_device_or_address = ENXIO,
Chris@16 106 no_such_device = ENODEV,
Chris@16 107 no_such_file_or_directory = ENOENT,
Chris@16 108 no_such_process = ESRCH,
Chris@16 109 not_a_directory = ENOTDIR,
Chris@16 110 not_a_socket = ENOTSOCK,
Chris@16 111 not_a_stream = ENOSTR,
Chris@16 112 not_connected = ENOTCONN,
Chris@16 113 not_enough_memory = ENOMEM,
Chris@16 114 not_supported = ENOTSUP,
Chris@16 115 operation_canceled = ECANCELED,
Chris@16 116 operation_in_progress = EINPROGRESS,
Chris@16 117 operation_not_permitted = EPERM,
Chris@16 118 operation_not_supported = EOPNOTSUPP,
Chris@16 119 operation_would_block = EWOULDBLOCK,
Chris@16 120 owner_dead = EOWNERDEAD,
Chris@16 121 permission_denied = EACCES,
Chris@16 122 protocol_error = EPROTO,
Chris@16 123 protocol_not_supported = EPROTONOSUPPORT,
Chris@16 124 read_only_file_system = EROFS,
Chris@16 125 resource_deadlock_would_occur = EDEADLK,
Chris@16 126 resource_unavailable_try_again = EAGAIN,
Chris@16 127 result_out_of_range = ERANGE,
Chris@16 128 state_not_recoverable = ENOTRECOVERABLE,
Chris@16 129 stream_timeout = ETIME,
Chris@16 130 text_file_busy = ETXTBSY,
Chris@16 131 timed_out = ETIMEDOUT,
Chris@16 132 too_many_files_open_in_system = ENFILE,
Chris@16 133 too_many_files_open = EMFILE,
Chris@16 134 too_many_links = EMLINK,
Chris@16 135 too_many_symbolic_link_levels = ELOOP,
Chris@16 136 value_too_large = EOVERFLOW,
Chris@16 137 wrong_protocol_type = EPROTOTYPE
Chris@16 138 };
Chris@16 139
Chris@16 140 } // namespace errc
Chris@16 141
Chris@16 142 # ifndef BOOST_SYSTEM_NO_DEPRECATED
Chris@16 143 namespace posix = errc;
Chris@16 144 namespace posix_error = errc;
Chris@16 145 # endif
Chris@16 146
Chris@16 147 template<> struct is_error_condition_enum<errc::errc_t>
Chris@16 148 { static const bool value = true; };
Chris@16 149
Chris@16 150
Chris@16 151 // ----------------------------------------------------------------------//
Chris@16 152
Chris@16 153 // Operating system specific interfaces --------------------------------//
Chris@16 154
Chris@16 155
Chris@16 156 // The interface is divided into general and system-specific portions to
Chris@16 157 // meet these requirements:
Chris@16 158 //
Chris@16 159 // * Code calling an operating system API can create an error_code with
Chris@16 160 // a single category (system_category), even for POSIX-like operating
Chris@16 161 // systems that return some POSIX errno values and some native errno
Chris@16 162 // values. This code should not have to pay the cost of distinguishing
Chris@16 163 // between categories, since it is not yet known if that is needed.
Chris@16 164 //
Chris@16 165 // * Users wishing to write system-specific code should be given enums for
Chris@16 166 // at least the common error cases.
Chris@16 167 //
Chris@16 168 // * System specific code should fail at compile time if moved to another
Chris@16 169 // operating system.
Chris@16 170
Chris@16 171 // The system specific portions of the interface are located in headers
Chris@16 172 // with names reflecting the operating system. For example,
Chris@16 173 //
Chris@16 174 // <boost/system/cygwin_error.hpp>
Chris@16 175 // <boost/system/linux_error.hpp>
Chris@16 176 // <boost/system/windows_error.hpp>
Chris@16 177 //
Chris@16 178 // These headers are effectively empty for compiles on operating systems
Chris@16 179 // where they are not applicable.
Chris@16 180
Chris@16 181 // ----------------------------------------------------------------------//
Chris@16 182
Chris@16 183 // class error_category ------------------------------------------------//
Chris@16 184
Chris@16 185 class error_category : public noncopyable
Chris@16 186 {
Chris@16 187 public:
Chris@16 188 virtual ~error_category(){}
Chris@16 189
Chris@16 190 virtual const char * name() const BOOST_SYSTEM_NOEXCEPT = 0;
Chris@16 191 virtual std::string message( int ev ) const = 0;
Chris@16 192 inline virtual error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT;
Chris@16 193 inline virtual bool equivalent( int code,
Chris@16 194 const error_condition & condition ) const BOOST_SYSTEM_NOEXCEPT;
Chris@16 195 inline virtual bool equivalent( const error_code & code,
Chris@16 196 int condition ) const BOOST_SYSTEM_NOEXCEPT;
Chris@16 197
Chris@16 198 bool operator==(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT { return this == &rhs; }
Chris@16 199 bool operator!=(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT { return this != &rhs; }
Chris@16 200 bool operator<( const error_category & rhs ) const BOOST_SYSTEM_NOEXCEPT
Chris@16 201 {
Chris@16 202 return std::less<const error_category*>()( this, &rhs );
Chris@16 203 }
Chris@16 204 };
Chris@16 205
Chris@16 206 // predefined error categories -----------------------------------------//
Chris@16 207
Chris@16 208 # ifdef BOOST_ERROR_CODE_HEADER_ONLY
Chris@16 209 inline const error_category & system_category() BOOST_SYSTEM_NOEXCEPT;
Chris@16 210 inline const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT;
Chris@16 211 #else
Chris@16 212 BOOST_SYSTEM_DECL const error_category & system_category() BOOST_SYSTEM_NOEXCEPT;
Chris@16 213 BOOST_SYSTEM_DECL const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT;
Chris@16 214 #endif
Chris@16 215 // deprecated synonyms --------------------------------------------------//
Chris@16 216
Chris@16 217 # ifndef BOOST_SYSTEM_NO_DEPRECATED
Chris@16 218 inline const error_category & get_system_category() { return system_category(); }
Chris@16 219 inline const error_category & get_generic_category() { return generic_category(); }
Chris@16 220 inline const error_category & get_posix_category() { return generic_category(); }
Chris@16 221 static const error_category & posix_category = generic_category();
Chris@16 222 static const error_category & errno_ecat = generic_category();
Chris@16 223 static const error_category & native_ecat = system_category();
Chris@16 224 # endif
Chris@16 225
Chris@16 226 // class error_condition -----------------------------------------------//
Chris@16 227
Chris@16 228 // error_conditions are portable, error_codes are system or library specific
Chris@16 229
Chris@16 230 class error_condition
Chris@16 231 {
Chris@16 232 public:
Chris@16 233
Chris@16 234 // constructors:
Chris@16 235 error_condition() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&generic_category()) {}
Chris@16 236 error_condition( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT : m_val(val), m_cat(&cat) {}
Chris@16 237
Chris@16 238 template <class ErrorConditionEnum>
Chris@16 239 error_condition(ErrorConditionEnum e,
Chris@16 240 typename boost::enable_if<is_error_condition_enum<ErrorConditionEnum> >::type* = 0) BOOST_SYSTEM_NOEXCEPT
Chris@16 241 {
Chris@16 242 *this = make_error_condition(e);
Chris@16 243 }
Chris@16 244
Chris@16 245 // modifiers:
Chris@16 246
Chris@16 247 void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
Chris@16 248 {
Chris@16 249 m_val = val;
Chris@16 250 m_cat = &cat;
Chris@16 251 }
Chris@16 252
Chris@16 253 template<typename ErrorConditionEnum>
Chris@16 254 typename boost::enable_if<is_error_condition_enum<ErrorConditionEnum>, error_condition>::type &
Chris@16 255 operator=( ErrorConditionEnum val ) BOOST_SYSTEM_NOEXCEPT
Chris@16 256 {
Chris@16 257 *this = make_error_condition(val);
Chris@16 258 return *this;
Chris@16 259 }
Chris@16 260
Chris@16 261 void clear() BOOST_SYSTEM_NOEXCEPT
Chris@16 262 {
Chris@16 263 m_val = 0;
Chris@16 264 m_cat = &generic_category();
Chris@16 265 }
Chris@16 266
Chris@16 267 // observers:
Chris@16 268 int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; }
Chris@16 269 const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; }
Chris@16 270 std::string message() const { return m_cat->message(value()); }
Chris@16 271
Chris@16 272 typedef void (*unspecified_bool_type)();
Chris@16 273 static void unspecified_bool_true() {}
Chris@16 274
Chris@16 275 operator unspecified_bool_type() const BOOST_SYSTEM_NOEXCEPT // true if error
Chris@16 276 {
Chris@16 277 return m_val == 0 ? 0 : unspecified_bool_true;
Chris@16 278 }
Chris@16 279
Chris@16 280 bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error
Chris@16 281 {
Chris@16 282 return m_val == 0;
Chris@16 283 }
Chris@16 284
Chris@16 285 // relationals:
Chris@16 286 // the more symmetrical non-member syntax allows enum
Chris@16 287 // conversions work for both rhs and lhs.
Chris@16 288 inline friend bool operator==( const error_condition & lhs,
Chris@16 289 const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT
Chris@16 290 {
Chris@16 291 return lhs.m_cat == rhs.m_cat && lhs.m_val == rhs.m_val;
Chris@16 292 }
Chris@16 293
Chris@16 294 inline friend bool operator<( const error_condition & lhs,
Chris@16 295 const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT
Chris@16 296 // the more symmetrical non-member syntax allows enum
Chris@16 297 // conversions work for both rhs and lhs.
Chris@16 298 {
Chris@16 299 return lhs.m_cat < rhs.m_cat
Chris@16 300 || (lhs.m_cat == rhs.m_cat && lhs.m_val < rhs.m_val);
Chris@16 301 }
Chris@16 302
Chris@16 303 private:
Chris@16 304 int m_val;
Chris@16 305 const error_category * m_cat;
Chris@16 306
Chris@16 307 };
Chris@16 308
Chris@16 309 // class error_code ----------------------------------------------------//
Chris@16 310
Chris@16 311 // We want error_code to be a value type that can be copied without slicing
Chris@16 312 // and without requiring heap allocation, but we also want it to have
Chris@16 313 // polymorphic behavior based on the error category. This is achieved by
Chris@16 314 // abstract base class error_category supplying the polymorphic behavior,
Chris@16 315 // and error_code containing a pointer to an object of a type derived
Chris@16 316 // from error_category.
Chris@16 317 class error_code
Chris@16 318 {
Chris@16 319 public:
Chris@16 320
Chris@16 321 // constructors:
Chris@16 322 error_code() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&system_category()) {}
Chris@16 323 error_code( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT : m_val(val), m_cat(&cat) {}
Chris@16 324
Chris@16 325 template <class ErrorCodeEnum>
Chris@16 326 error_code(ErrorCodeEnum e,
Chris@16 327 typename boost::enable_if<is_error_code_enum<ErrorCodeEnum> >::type* = 0) BOOST_SYSTEM_NOEXCEPT
Chris@16 328 {
Chris@16 329 *this = make_error_code(e);
Chris@16 330 }
Chris@16 331
Chris@16 332 // modifiers:
Chris@16 333 void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
Chris@16 334 {
Chris@16 335 m_val = val;
Chris@16 336 m_cat = &cat;
Chris@16 337 }
Chris@16 338
Chris@16 339 template<typename ErrorCodeEnum>
Chris@16 340 typename boost::enable_if<is_error_code_enum<ErrorCodeEnum>, error_code>::type &
Chris@16 341 operator=( ErrorCodeEnum val ) BOOST_SYSTEM_NOEXCEPT
Chris@16 342 {
Chris@16 343 *this = make_error_code(val);
Chris@16 344 return *this;
Chris@16 345 }
Chris@16 346
Chris@16 347 void clear() BOOST_SYSTEM_NOEXCEPT
Chris@16 348 {
Chris@16 349 m_val = 0;
Chris@16 350 m_cat = &system_category();
Chris@16 351 }
Chris@16 352
Chris@16 353 // observers:
Chris@16 354 int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; }
Chris@16 355 const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; }
Chris@16 356 error_condition default_error_condition() const BOOST_SYSTEM_NOEXCEPT { return m_cat->default_error_condition(value()); }
Chris@16 357 std::string message() const { return m_cat->message(value()); }
Chris@16 358
Chris@16 359 typedef void (*unspecified_bool_type)();
Chris@16 360 static void unspecified_bool_true() {}
Chris@16 361
Chris@16 362 operator unspecified_bool_type() const BOOST_SYSTEM_NOEXCEPT // true if error
Chris@16 363 {
Chris@16 364 return m_val == 0 ? 0 : unspecified_bool_true;
Chris@16 365 }
Chris@16 366
Chris@16 367 bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error
Chris@16 368 {
Chris@16 369 return m_val == 0;
Chris@16 370 }
Chris@16 371
Chris@16 372 // relationals:
Chris@16 373 inline friend bool operator==( const error_code & lhs,
Chris@16 374 const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT
Chris@16 375 // the more symmetrical non-member syntax allows enum
Chris@16 376 // conversions work for both rhs and lhs.
Chris@16 377 {
Chris@16 378 return lhs.m_cat == rhs.m_cat && lhs.m_val == rhs.m_val;
Chris@16 379 }
Chris@16 380
Chris@16 381 inline friend bool operator<( const error_code & lhs,
Chris@16 382 const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT
Chris@16 383 // the more symmetrical non-member syntax allows enum
Chris@16 384 // conversions work for both rhs and lhs.
Chris@16 385 {
Chris@16 386 return lhs.m_cat < rhs.m_cat
Chris@16 387 || (lhs.m_cat == rhs.m_cat && lhs.m_val < rhs.m_val);
Chris@16 388 }
Chris@16 389
Chris@16 390 private:
Chris@16 391 int m_val;
Chris@16 392 const error_category * m_cat;
Chris@16 393
Chris@16 394 };
Chris@16 395
Chris@16 396 // predefined error_code object used as "throw on error" tag
Chris@16 397 # ifndef BOOST_SYSTEM_NO_DEPRECATED
Chris@16 398 BOOST_SYSTEM_DECL extern error_code throws;
Chris@16 399 # endif
Chris@16 400
Chris@16 401 // Moving from a "throws" object to a "throws" function without breaking
Chris@16 402 // existing code is a bit of a problem. The workaround is to place the
Chris@16 403 // "throws" function in namespace boost rather than namespace boost::system.
Chris@16 404
Chris@16 405 } // namespace system
Chris@16 406
Chris@16 407 namespace detail { inline system::error_code * throws() { return 0; } }
Chris@16 408 // Misuse of the error_code object is turned into a noisy failure by
Chris@16 409 // poisoning the reference. This particular implementation doesn't
Chris@16 410 // produce warnings or errors from popular compilers, is very efficient
Chris@16 411 // (as determined by inspecting generated code), and does not suffer
Chris@16 412 // from order of initialization problems. In practice, it also seems
Chris@16 413 // cause user function error handling implementation errors to be detected
Chris@16 414 // very early in the development cycle.
Chris@16 415
Chris@16 416 inline system::error_code & throws()
Chris@16 417 { return *detail::throws(); }
Chris@16 418
Chris@16 419 namespace system
Chris@16 420 {
Chris@16 421 // non-member functions ------------------------------------------------//
Chris@16 422
Chris@16 423 inline bool operator!=( const error_code & lhs,
Chris@16 424 const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT
Chris@16 425 {
Chris@16 426 return !(lhs == rhs);
Chris@16 427 }
Chris@16 428
Chris@16 429 inline bool operator!=( const error_condition & lhs,
Chris@16 430 const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT
Chris@16 431 {
Chris@16 432 return !(lhs == rhs);
Chris@16 433 }
Chris@16 434
Chris@16 435 inline bool operator==( const error_code & code,
Chris@16 436 const error_condition & condition ) BOOST_SYSTEM_NOEXCEPT
Chris@16 437 {
Chris@16 438 return code.category().equivalent( code.value(), condition )
Chris@16 439 || condition.category().equivalent( code, condition.value() );
Chris@16 440 }
Chris@16 441
Chris@16 442 inline bool operator!=( const error_code & lhs,
Chris@16 443 const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT
Chris@16 444 {
Chris@16 445 return !(lhs == rhs);
Chris@16 446 }
Chris@16 447
Chris@16 448 inline bool operator==( const error_condition & condition,
Chris@16 449 const error_code & code ) BOOST_SYSTEM_NOEXCEPT
Chris@16 450 {
Chris@16 451 return condition.category().equivalent( code, condition.value() )
Chris@16 452 || code.category().equivalent( code.value(), condition );
Chris@16 453 }
Chris@16 454
Chris@16 455 inline bool operator!=( const error_condition & lhs,
Chris@16 456 const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT
Chris@16 457 {
Chris@16 458 return !(lhs == rhs);
Chris@16 459 }
Chris@16 460
Chris@16 461 // TODO: both of these may move elsewhere, but the LWG hasn't spoken yet.
Chris@16 462
Chris@16 463 template <class charT, class traits>
Chris@16 464 inline std::basic_ostream<charT,traits>&
Chris@16 465 operator<< (std::basic_ostream<charT,traits>& os, error_code ec)
Chris@16 466 {
Chris@16 467 os << ec.category().name() << ':' << ec.value();
Chris@16 468 return os;
Chris@16 469 }
Chris@16 470
Chris@16 471 inline std::size_t hash_value( const error_code & ec )
Chris@16 472 {
Chris@16 473 return static_cast<std::size_t>(ec.value())
Chris@16 474 + reinterpret_cast<std::size_t>(&ec.category());
Chris@16 475 }
Chris@16 476
Chris@16 477 // make_* functions for errc::errc_t -----------------------------//
Chris@16 478
Chris@16 479 namespace errc
Chris@16 480 {
Chris@16 481 // explicit conversion:
Chris@16 482 inline error_code make_error_code( errc_t e ) BOOST_SYSTEM_NOEXCEPT
Chris@16 483 { return error_code( e, generic_category() ); }
Chris@16 484
Chris@16 485 // implicit conversion:
Chris@16 486 inline error_condition make_error_condition( errc_t e ) BOOST_SYSTEM_NOEXCEPT
Chris@16 487 { return error_condition( e, generic_category() ); }
Chris@16 488 }
Chris@16 489
Chris@16 490 // error_category default implementation -------------------------------//
Chris@16 491
Chris@16 492 error_condition error_category::default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT
Chris@16 493 {
Chris@16 494 return error_condition( ev, *this );
Chris@16 495 }
Chris@16 496
Chris@16 497 bool error_category::equivalent( int code,
Chris@16 498 const error_condition & condition ) const BOOST_SYSTEM_NOEXCEPT
Chris@16 499 {
Chris@16 500 return default_error_condition( code ) == condition;
Chris@16 501 }
Chris@16 502
Chris@16 503 bool error_category::equivalent( const error_code & code,
Chris@16 504 int condition ) const BOOST_SYSTEM_NOEXCEPT
Chris@16 505 {
Chris@16 506 return *this == code.category() && code.value() == condition;
Chris@16 507 }
Chris@16 508
Chris@16 509 } // namespace system
Chris@16 510 } // namespace boost
Chris@16 511
Chris@16 512 #include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
Chris@16 513
Chris@16 514 # ifdef BOOST_ERROR_CODE_HEADER_ONLY
Chris@101 515 # include <boost/system/detail/error_code.ipp>
Chris@16 516 # endif
Chris@16 517
Chris@16 518 #endif // BOOST_ERROR_CODE_HPP
Chris@16 519
Chris@16 520