4 <meta http-equiv=
"Content-Language" content=
"en-us">
5 <meta name=
"GENERATOR" content=
"Microsoft FrontPage 5.0">
6 <meta name=
"ProgId" content=
"FrontPage.Editor.Document">
7 <meta http-equiv=
"Content-Type" content=
"text/html; charset=windows-1252">
8 <title>System Library Reference
</title>
9 <link rel=
"stylesheet" type=
"text/css" href=
"../../../doc/html/minimal.css">
14 <table border=
"0" cellpadding=
"5" cellspacing=
"0" style=
"border-collapse: collapse" bordercolor=
"#111111" width=
"637">
17 <a href=
"../../../index.htm">
18 <img src=
"../../../boost.png" alt=
"boost.png (6897 bytes)" align=
"middle" width=
"277" height=
"86" border=
"0"></a></td>
19 <td width=
"337" align=
"middle">
20 <font size=
"7">System Library
</font>
25 <table border=
"0" cellpadding=
"5" cellspacing=
"0" style=
"border-collapse: collapse" bordercolor=
"#111111" bgcolor=
"#D7EEFF" width=
"100%">
27 <td><a href=
"../../../index.htm">Boost Home
</a> <a href=
"index.html">
28 Library Home
</a> Tutorial
<a href=
"reference.html">
33 <table border=
"1" cellpadding=
"5" cellspacing=
"0" style=
"border-collapse: collapse" bordercolor=
"#111111" align=
"right">
35 <td width=
"100%" bgcolor=
"#D7EEFF" align=
"center">
36 <i><b>Contents
</b></i></td>
39 <td width=
"100%" bgcolor=
"#E8F5FF">
40 <a href=
"#Introduction">Introduction
</a><br>
41 <a href=
"#Macros">Macros
</a><br>
42 <a href=
"#Header-error_code">Header
<boost/system/error_code.hpp
></a><br>
43 <a href=
"#Class-error_category">Class
<code>error_category
</code></a><br>
44 <a href=
"#Class-error_category-synopsis">Class
<code>error_category
</code> synopsis
</a><br>
45 <a href=
"#Class-error_category-virtual-members">Class
<code>error_category
</code> virtual members
</a><br>
46 <a href=
"#Class-error_category-non-virtual-members">Class
<code>error_category
</code> non-virtual members
</a><br>
47 <a href=
"#Class-error_category-non-member-functions">Class
<code>error_category
</code>
48 non-member functions
</a><br>
49 <a href=
"#Class-error_category-predefined-objects">Class
<code>error_category
</code> predefined objects
</a><br>
50 <a href=
"#Class-error_code">Class
<code>error_code
</code></a><br>
51 <a href=
"#Class-error_code-synopsis">Class
<code>error_code
</code> synopsis
</a><br>
52 <a href=
"#Class-error_code-constructors">Class
<code>error_code
</code> constructors
</a><br>
53 <a href=
"#Class-error_code-modifiers">Class
<code>error_code
</code> modifiers
</a><br>
54 <a href=
"#Class-error_code-observers">Class
<code>error_code
</code> observers
</a><br>
55 <a href=
"#Class-error_condition</code>">Class
<code>error_condition
</code></a><br>
56 <a href=
"#Class-error_condition-synopsis">Class
<code>error_condition
</code> synopsis
</a><br>
57 <a href=
"#Class-error_condition-constructors">Class
<code>error_condition
</code> constructors
</a><br>
58 <a href=
"#Class-error_condition-modifiers">Class
<code>error_condition
</code> modifiers
</a><br>
59 <a href=
"#Class-error_condition-observers">Class
<code>error_condition
</code> observers
</a><br>
60 <a href=
"#throws-object"><code>throws
</code> object
</a><br>
61 <a href=
"#Semantics-of-throws">Semantics of
<code>throws
</code> object
</a><br>
62 <a href=
"#Non-member-functions">Non-member functions
</a><br>
63 <a href=
"#Header-system_error">Header
<boost/system/system_error.hpp
></a><br>
64 <a href=
"#Class-system_error">Class
<code>system_error
</code></a><br>
69 <h2><a name=
"Introduction">Introduction
</a></h2>
71 <p>This reference documentation describes components that
72 programs may use to report error conditions originating from the operating
73 system or other low-level application program interfaces.
</p>
74 <p>Boost.System library components never change the value of
<code>
76 <h2><a name=
"Macros">Macros
</a></h2>
77 <p>Users may defined the following macros if desired. Sensible defaults are
78 provided, so users may ignore these macros if they prefer.
</p>
79 <table border=
"1" cellpadding=
"5" cellspacing=
"0" style=
"border-collapse: collapse" bordercolor=
"#111111">
81 <td><b><i>Macro Name
</i></b></td>
82 <td><b><i>Default
</i></b></td>
83 <td><b><i>Effect if defined
</i></b></td>
86 <td valign=
"top"><code>BOOST_WINDOWS_API
</code></td>
87 <td valign=
"top">Defined if Windows is detected by Boost.System's automatic configuration
88 code, otherwise not defined.
</td>
89 <td valign=
"top">Implementation uses the Microsoft Windows native
90 application program interface (API).
</td>
93 <td valign=
"top"><code>BOOST_POSIX_API
</code></td>
94 <td valign=
"top">Defined if Windows is not detected by Boost.System's automatic configuration
96 <td valign=
"top">Implementation uses the POSIX native
97 application program interface (API).
</td>
100 <td valign=
"top"><code>BOOST_SYSTEM_DYN_LINK
</code></td>
101 <td valign=
"top">Defined if
<code>BOOST_ALL_DYN_LINK
</code> is defined,
102 otherwise not defined.
</td>
103 <td valign=
"top">Boost.System library is dynamically linked. If not defined,
104 static linking is assumed.
</td>
107 <td valign=
"top"><code>BOOST_SYSTEM_NO_LIB
</code></td>
108 <td valign=
"top">Defined if
<code>BOOST_ALL_NO_LIB
</code> is defined,
109 otherwise not defined.
</td>
110 <td valign=
"top">Boost.System library does not use the Boost auto-link
114 <td valign=
"top"><code>BOOST_SYSTEM_NO_DEPRECATED
</code></td>
115 <td valign=
"top">Not defined.
</td>
116 <td valign=
"top">Deprecated features are excluded.
</td>
119 <h2><a name=
"Header-error_code">Header
<boost/system/error_code.hpp
></a></h2>
120 <h3><boost/system/error_code.hpp
> synopsis
</h3>
126 class
<a href=
"#Class-error_category">error_category
</a>;
127 class
<a href=
"#Class-error_code">error_code
</a>;
128 class
<a href=
"#Class-error_condition">error_condition
</a>;
131 template< class
T=
"" >
132 struct is_error_code_enum { static const bool value = false; };
134 template< class
T=
"" >
135 struct is_error_condition_enum { static const bool value = false; };
137 // generic error_conditions
143 address_family_not_supported, //EAFNOSUPPORT
144 address_in_use, //EADDRINUSE
145 address_not_available, //EADDRNOTAVAIL
146 already_connected, //EISCONN
147 argument_list_too_long, //E2BIG
148 argument_out_of_domain, //EDOM
149 bad_address, //EFAULT
150 bad_file_descriptor, //EBADF
151 bad_message, //EBADMSG
153 connection_aborted, //ECONNABORTED
154 connection_already_in_progress, //EALREADY
155 connection_refused, //ECONNREFUSED
156 connection_reset, //ECONNRESET
157 cross_device_link, //EXDEV
158 destination_address_required, //EDESTADDRREQ
159 device_or_resource_busy, //EBUSY
160 directory_not_empty, //ENOTEMPTY
161 executable_format_error, //ENOEXEC
162 file_exists, //EEXIST
163 file_too_large, //EFBIG
164 filename_too_long, //ENAMETOOLONG
165 function_not_supported, //ENOSYS
166 host_unreachable, //EHOSTUNREACH
167 identifier_removed, //EIDRM
168 illegal_byte_sequence, //EILSEQ
169 inappropriate_io_control_operation,//ENOTTY
171 invalid_argument, //EINVAL
172 invalid_seek, //ESPIPE
174 is_a_directory, //EISDIR
175 message_size, //EMSGSIZE
176 network_down, //ENETDOWN
177 network_reset, //ENETRESET
178 network_unreachable, //ENETUNREACH
179 no_buffer_space, //ENOBUFS
180 no_child_process, //ECHILD
182 no_lock_available, //ENOLCK
183 no_message_available, //ENODATA
185 no_protocol_option, //ENOPROTOOPT
186 no_space_on_device, //ENOSPC
187 no_stream_resources, //ENOSR
188 no_such_device_or_address, //ENXIO
189 no_such_device, //ENODEV
190 no_such_file_or_directory, //ENOENT
191 no_such_process, //ESRCH
192 not_a_directory, //ENOTDIR
193 not_a_socket, //ENOTSOCK
194 not_a_stream, //ENOSTR
195 not_connected, //ENOTCONN
196 not_enough_memory, //ENOMEM
197 not_supported, //ENOTSUP
198 operation_canceled, //ECANCELED
199 operation_in_progress, //EINPROGRESS
200 operation_not_permitted, //EPERM
201 operation_not_supported, //EOPNOTSUPP
202 operation_would_block, //EWOULDBLOCK
203 owner_dead, //EOWNERDEAD
204 permission_denied, //EACCES
205 protocol_error, //EPROTO
206 protocol_not_supported, //EPROTONOSUPPORT
207 read_only_file_system, //EROFS
208 resource_deadlock_would_occur, //EDEADLK
209 resource_unavailable_try_again, //EAGAIN
210 result_out_of_range, //ERANGE
211 state_not_recoverable, //ENOTRECOVERABLE
212 stream_timeout, //ETIME
213 text_file_busy, //ETXTBSY
214 timed_out, //ETIMEDOUT
215 too_many_files_open_in_system, //ENFILE
216 too_many_files_open, //EMFILE
217 too_many_links, //EMLINK
218 too_many_synbolic_link_levels, //ELOOP
219 value_too_large, //EOVERFLOW
220 wrong_protocol_type //EPROTOTYPE
225 template<
> struct is_error_condition_enum
<posix::posix_errno><errc::errc_t
>
226 { static const bool value = true; };
228 // predefined error_code object used as
"throw on error
" tag
229 extern error_code
<a href=
"#throws-object">throws
</a>;
231 //
<a href=
"#Non-member-functions">non-member functions
</a>
233 bool operator==( const error_code
& lhs, const error_code
& rhs );
234 bool operator==( const error_code
& code, const error_condition
& condition );
235 bool operator==( const error_condition
& condition, const error_code
& code );
236 bool operator==( const error_condition
& lhs, const error_condition
& rhs );
238 bool operator!=( const error_code
& lhs, const error_code
& rhs );
239 bool operator!=( const error_code
& code, const error_condition
& condition );
240 bool operator!=( const error_condition
& condition, const error_code
& code );
241 bool operator!=( const error_condition
& lhs, const error_condition
& rhs );
243 bool operator
<( const error_code
& lhs, const error_code
& rhs );
244 bool operator
<( const error_condition
& lhs, const error_condition
& rhs );
246 error_code make_error_code( errc::errc_t e );
247 error_condition make_error_condition( errc::errc_t e );
249 template
<class charT, class traits
>
250 std::basic_ostream
<charT,traits
>&
251 operator
<<( basic_ostream
<charT,traits
>& os, const error_code
& ec );
253 size_t hash_value( const error_code
& ec );
257 <p>The value of each
<code> errc_t
</code> constant shall be the same as the
258 value of the
<code><cerrno
></code> macro shown in the above synopsis.
</p>
259 <p>Users may specialize
<code>is_error_code_enum
</code> and
<code>
260 is_error_condition_enum
</code> templates to indicate that a type is eligible for
261 class
<code>error_code
</code> and
<code>error_condition
</code> automatic
262 conversions respectively.
</p>
264 <h2><a name=
"Class-error_category">Class
<code>error_category
</code></a></h2>
265 <p>The class
<code>error_category
</code> defines the base class for types used
266 to identify the source and encoding of a particular category of error code.
</p>
267 <p><i>[Note:
</i> Classes may be derived from
<code>error_category
</code>
268 to support additional categories of errors.
<i>--end note]
</i></p>
269 <p>The class
<code>error_category
</code> serves as a base class for types used
270 to identify the source and encoding of a particular category of error code.
271 Classes may be derived from
<code>error_category
</code> to support categories of
272 errors in addition to those defined in the Boost System library. Such classes
273 shall behave as specified in this subclause. [
<i> Note:
</i> <code>error_category
</code>
274 objects are passed by reference, and two such objects are equal if they have the
275 same address. This means that applications using custom
<code>error_category
</code>
276 types should create a single object of each such type.
<i>—end note
</i> ]
</p>
277 <h3><a name=
"Class-error_category-synopsis">Class
<code>error_category
</code> synopsis
</a></h3>
283 class error_category : public noncopyable
286 virtual ~error_category();
288 virtual const char * name() const =
0;
289 virtual string message( error_code::value_type ev ) const =
0;
290 virtual error_condition default_error_condition( int ev ) const;
291 virtual bool equivalent( int code, const error_condition
& condition ) const;
292 virtual bool equivalent( const error_code
& code, int condition ) const;
294 bool operator==( const error_category
& rhs ) const;
295 bool operator!=( const error_category
& rhs ) const;
296 bool operator
< ( const error_category
& rhs ) const;
299 const error_category
& get_system_category();
300 const error_category
& get_generic_category();
302 static const error_category
& system_category = get_system_category();
303 static const error_category
& generic_category = get_generic_category();
307 <h3><a name=
"Class-error_category-virtual-members">Class
<code>error_category
</code> virtual members
</a></h3>
308 <p>Classes derived from
<code>error_category
</code> shall behave as specified in
310 <pre>virtual const char * name() const=
0;
</pre>
312 <p><i>Returns:
</i>a string naming the error category.
</p>
313 <p><i>Throws:
</i> Nothing.
</p>
315 <pre>virtual string message( error_code::value_type ev ) const=
0;
</pre>
317 <p><i>Returns:
</i> A string that describes the error denoted by
319 <p><i>Throws:
</i> Nothing.
</p>
321 <p><code>virtual error_condition default_error_condition( int ev ) const;
</code></p>
323 <p><i>Returns:
</i> <code>error_condition( ev, *this )
</code>.
</p>
325 <p> [
<i>--Note:
</i> Derived classes will typically convert
<code>ev
</code>
326 to some portable
<code>error_category
</code>, such as
<code>generic_category
</code>,
327 and return it as an
<code>error_condition
</code> for that category.
<i>--end
330 <p><i>Throws:
</i> Nothing.
</p>
332 <p><code>virtual bool equivalent( int code, const error_condition
&
336 <p><i>Returns:
</i> <code>default_error_condition( code ) == condition
</code>.
</p>
337 <p><i>Throws:
</i> Nothing.
</p>
339 <p><code>virtual bool equivalent( const error_code
& code, int condition ) const;
</code></p>
341 <p><i>Returns:
</i> <code>*this == code.category()
&& code.value() == condition
</code>.
</p>
342 <p><i>Throws:
</i> Nothing.
</p>
344 <h3><a name=
"Class-error_category-non-virtual-members">Class
<code>error_category
</code> non-virtual members
</a></h3>
345 <p><code>bool operator==( const error_category
& rhs ) const;
</code></p>
347 <p><i>Returns:
</i> <code>this ==
&rhs
</code>.
</p>
349 <p><code>bool operator!=( const error_category
& rhs ) const;
</code></p>
351 <p><i>Returns:
</i> <code>this !=
&rhs
</code>.
</p>
354 <pre>bool operator
<( const error_category
& rhs ) const;
</pre>
356 <p><i>Returns:
</i> <code>std::less
<const error_category*
>()( this,
&rhs )
</code>.
</p>
358 <p><i>[Note:
</i> <code>std::less
</code> provides a total ordering for
359 pointers.
<i>--end note]
</i></p>
361 <p><i>Throws:
</i> Nothing.
</p>
363 <h3><a name=
"Class-error_category-non-member-functions">Class
<code>error_category
</code>
364 non-member functions
</a></h3>
365 <pre>const error_category
& get_system_category();
</pre>
367 <p><i>Returns:
</i> A reference to a
<code>error_category
</code> object
368 identifying errors originating from the operating system.
</p>
369 <p><i>Throws:
</i> Nothing.
</p>
371 <pre>const error_category
& get_generic_category();
</pre>
373 <p><i>Returns:
</i> A reference to a
<code>error_category
</code> object
374 identifying portable error conditions.
</p>
375 <p><i>Throws:
</i> Nothing.
</p>
377 <h3><a name=
"Class-error_category-predefined-objects">Class
<code>error_category
</code>
378 predefined objects
</a></h3>
379 <p>Predefined objects
<code>system_category
</code>
380 and
<code>generic_category
</code> identify system specific error codes and portable error conditions, respectively.
</p>
381 <h2><a name=
"Class-error_code">Class
<code>
382 error_code
</code></a></h2>
383 <p>The class
<code>error_code
</code> describes an object used to hold error code
384 values, such as those originating from the operating
<br>
385 system or other low-level application program interfaces.
<i>[ Note:
</i>Class
386 <code>error_code
</code> is an adjunct to error reporting by
<br>
387 exception.
<i>—end note ]
</i></p>
388 <h3><a name=
"Class-error_code-synopsis">Class
<code>
389 error_code
</code> synopsis
</a></h3>
400 error_code( val, const error_category
& cat );
401 template
<class
<code>ErrorCodeEnum
</code>>
402 error_code(
<code> errorCodeEnum
</code> e,
403 typename enable_if
<is_error_code_enum
<<code>ErrorCodeEnum
</code>> >::type* =
0);
406 void assign( int val, const error_category
& cat );
407 template
<typename
<code>ErrorCodeEnum
</code>>
408 typename enable_if
<is_error_code_enum
<<code>ErrorCodeEnum
</code>>, error_code
>::type
&
409 operator=(
<code>ErrorCodeEnum
</code> val );;
414 cont error_category
& category() const;
415 error_condition default_error_condition() const;
416 string message() const;
417 operator unspecified-bool-type() const;
420 int val_; //
<i>exposition only
</i>
421 const error_category
& cat_; //
<i>exposition only
</i>
426 <h3><a name=
"Class-error_code-constructors">Class
<code>
427 error_code
</code> constructors
</a></h3>
428 <pre>error_code();
</pre>
430 <p><i>Effects:
</i>Constructs an object of type
<code>error_code
</code>.
</p>
431 <p><i>Postconditions:
</i> <code>val_ ==
0 && cat_ ==
&system_category
</code>.
</p>
432 <p><i>Throws:
</i> Nothing.
</p>
434 <pre>error_code( int val, const error_category
& cat );
</pre>
436 <p><i>Effects:
</i>Constructs an object of type
<code>error_code
</code>.
</p>
437 <p><i>Postconditions:
</i> <code>val_ == val
&& cat_ ==
&cat
</code>.
</p>
438 <p><i>Throws:
</i> Nothing.
</p>
440 <pre>template
<class
<code>ErrorCodeEnum
</code>>
441 error_code(
<code> errorCodeEnum
</code> val,
442 typename enable_if
<is_error_code_enum
<<code>ErrorCodeEnum
</code>> >::type* =
0);
</pre>
444 <p><i>Effects:
</i>Constructs an object of type
<code>error_code
</code>.
</p>
445 <p><i>Postconditions:
</i> <code>*this == make_error_code( val )
</code>.
</p>
446 <p><i>Throws:
</i> Nothing.
</p>
448 <h3><a name=
"Class-error_code-modifiers">Class
<code>
449 error_code
</code> modifiers
</a></h3>
450 <pre>void assign( int val, const error_category
& cat );
</pre>
452 <p><i>Postconditions:
</i> <code>val_ == val
&& cat_ == cat
</code>.
</p>
453 <p><i>Throws:
</i> Nothing.
</p>
455 <pre>template
<typename
<code>ErrorCodeEnum
</code>>
456 typename enable_if
<is_error_code_enum
<<code>ErrorCodeEnum
</code>>, error_code
>::type
&
457 operator=(
<code>ErrorCodeEnum
</code> val );
</pre>
459 <p><i>Postconditions:
</i> <code>*this == make_error_code( val )
</code>.
</p>
460 <p><i>Throws:
</i> Nothing.
</p>
462 <p><code>void clear();
</code></p>
464 <p><i>postcondition:
</i> <code>value() ==
0 && category() == generic_category
</code></p>
466 <h3><a name=
"Class-error_code-observers">Class
<code>
467 error_code
</code> observers
</a></h3>
468 <p><code>int value() const;
</code></p>
470 <p><i>Returns:
</i> <code>val_
</code>.
</p>
471 <p><i>Throws:
</i> Nothing.
</p>
473 <p><code>error_category category() const;
</code></p>
475 <p><i>Returns:
</i> <code>cat_
</code>.
</p>
476 <p><i>Throws:
</i> Nothing.
</p>
478 <pre>error_condition default_error_condition() const;
</pre>
480 <p><i>Returns:
</i> <code>category().default_error_condition( value())
</code>.
</p>
481 <p><i>Throws:
</i> Nothing.
</p>
483 <p><code>string message() const;
</code></p>
485 <p><i>Returns:
</i> <code>category().message( value())
</code>.
</p>
486 <p><i>Throws:
</i> Nothing.
</p>
488 <p><code>operator
<i>unspecified-bool-type
</i>() const;
</code></p>
490 <p><i>Returns:
</i> if
<code>value() != value_type()
</code>, returns a value that will evaluate
491 <code>true
</code> in a boolean context; otherwise, returns a value that will
492 evaluate
<code>false
</code> in a boolean context. The value type returned shall
493 not be convertible to
<code>int
</code>.
</p>
494 <p><i>Throws:
</i> nothing.
</p>
495 <p><i>[Note:
</i>This conversion can be used in contexts where a
<code>bool
</code>
496 is expected ( e.g., an
<code>if
</code> condition ); however, implicit conversions
497 ( e.g., to
<code>int
</code>) that can occur with
<code>bool
</code> are not
498 allowed, eliminating some sources of user error. One possible implementation
499 choice for this type is pointer-to-member.
<i>--end note ]
</i></p>
501 <h2><a name=
"Class-error_condition">Class
<code>error_condition
</code></a></h2>
502 <p>The class
<code>error_condition
</code> describes an object used to hold
503 values identifying error conditions.
<i>[ Note:
</i><code>error_condition
</code>
504 values are portable abstractions, while
<code>error_code
</code> values are
505 implementation specific.
<i>--end note ]
</i></p>
506 <h3><a name=
"Class-error_condition-synopsis">Class
<code>error_condition
</code> synopsis
</a></h3>
512 class error_condition
518 error_condition( int val, const error_category
& cat );
519 template
<class ErrorConditionEnum
>
520 error_condition( errorConditionEnum val,
521 typename enable_if
<is_error_condition_enum
<ErrorConditionEnum
> >::type* =
0 );
524 void assign( int val, const error_category
& cat );
525 template
<typename ErrorConditionEnum
>
526 typename enable_if
<is_error_condition_enum
<ErrorConditionEnum
>, error_code
>::type
&
527 operator=( ErrorConditionEnum val );
532 const error_category
& category() const;
533 string message() const;
534 operator unspecified-bool-type () const;
537 int val_; //
<i>exposition only
</i>
538 const error_category
& cat_; //
<i>exposition only
</i>
543 <h3><a name=
"Class-error_condition-constructors">Class
<code>error_condition
</code>
544 constructors
</a></h3>
545 <pre>error_condition();
</pre>
547 <p><i>Effects:
</i> Constructs an object of type
<code>error_condition
</code>.
</p>
548 <p><i>Postconditions:
</i> <code>val_ ==
0 and cat_ == generic_category
</code>.
</p>
549 <p><i>Throws:
</i> Nothing.
</p>
551 <pre>error_condition( value_type val, const error_category
& cat );
</pre>
553 <p><i>Effects:
</i>Constructs an object of type error_condition.
</p>
554 <p><i>Postconditions:
</i> <code>val_ == val and cat_ == cat
</code>.
</p>
555 <p><i>Throws:
</i> Nothing.
</p>
557 <pre>template
<class ErrorConditionEnum
>
558 error_condition( errorConditionEnum val,
559 typename enable_if
<is_error_condition_enum
<ErrorConditionEnum
> >::type* =
0 );
</pre>
561 <p><i>Effects:
</i> Constructs an object of type
<code>error_condition
</code>.
</p>
562 <p><i>Postconditions:
</i> <code>*this == make_error_condition( val )
</code>.
</p>
563 <p><i>Throws:
</i> Nothing.
</p>
565 <h3><a name=
"Class-error_condition-modifiers">Class
<code>error_condition
</code>
567 <pre>void assign( value_type val, const error_category
& cat );
</pre>
569 <p><i>Postconditions:
</i> <code>val_ == val and cat_ == cat
</code>.
</p>
570 <p><i>Throws:
</i> Nothing.
</p>
572 <pre>template
<typename ErrorConditionEnum
>
573 typename enable_if
<is_error_condition_enum
<ErrorConditionEnum
>, error_code
>::type
&
574 operator=( ErrorConditionEnum val );
</pre>
576 <p><i>Postconditions:
</i> <code>*this == make_error_condition( val )
</code>.
</p>
577 <p><i>Throws:
</i> Nothing.
</p>
579 <p><code>void clear();
</code></p>
581 <p><i>postcondition:
</i> <code>value() ==
0 && category() == generic_category
</code></p>
583 <h3><a name=
"Class-error_condition-observers">Class
<code>error_condition
</code>
585 <pre>value_type value() const;
</pre>
587 <p><i>Returns:
</i> <code>val_
</code>.
</p>
588 <p><i>Throws:
</i> Nothing
</p>
590 <pre>const error_category
& category() const;
</pre>
592 <p><i>Returns:
</i> <code>cat_
</code>.
</p>
593 <p>Throws: Nothing.
</p>
595 <pre>string message() const;
</pre>
597 <p><i>Returns:
</i> <code>category().message( value() )
</code>.
</p>
598 <p><i>Throws:
</i> Nothing.
</p>
600 <pre>operator unspecified-bool-type () const;
</pre>
602 <p><i>Returns:
</i>If
<code>value() !=
0</code>, returns a value that will
603 evaluate
<code>true
</code> in a boolean context; otherwise, returns a value
604 that will evaluate
<code>false
</code>. The return type shall not be
605 convertible to
<code>int
</code>.
</p>
606 <p><i>Throws:
</i> Nothing.
</p>
607 <p><i> [ Note:
</i> This conversion can be used in contexts where a
<code>bool
</code>
608 is expected ( e.g., an if condition ); however, implicit conversions ( e.g., to
609 <code>int
</code>) that can occur with
<code>bool
</code> are not allowed,
610 eliminating some sources of user error. One possible implementation choice for
611 this type is pointer to member.
<i>--end note
</i> <i>]
</i></p>
613 <h2><a name=
"throws-object"><code>throws
</code> object
</a></h2>
614 <pre>extern error_code throws;
</pre>
615 <p>The predefined
<code>error_code
</code> object
<code>throws
</code> is supplied
616 for use as a
"throw on error
" tag.
</p>
617 <h2><a name=
"Semantics-of-throws">Semantics of
<code>throws
</code></a> object
</h2>
618 <p>Functions that specify an argument in the form
<code>error_code
& ec=throws
</code>,
619 with appropriate namespace qualifiers, have the following error handling
622 <p><i>Effects:
</i> If
<code>ec != throws
</code>:
</p>
624 <li>If an error occurs, and sets
<code>ec
</code> to an appropriate
<code>
625 <a href=
"#Class-error_code">error_code
</a></code> that identifies the error
626 value and category. The category should be the most specific
<code>
627 <a href=
"#Class-error_category">error_category
</a></code> applicable to the
628 particular error.
</li>
629 <li>if an error does not occur,
<code>ec.clear()
</code>.
</li>
631 <p><i>Throws:
</i> If
<code>ec == throws
</code>, throws an exception of type
632 <code><a href=
"#Class-system_error">system_error
</a></code> or of a type
633 derived from
<code><a href=
"#Class-system_error">system_error
</a></code>.
</p>
635 <h2><a name=
"Non-member-functions">Non-member functions
</a></h2>
636 <pre>bool operator==( const error_code
& lhs, const error_code
& rhs );
</pre>
638 <p><i>Returns:
</i> <code>lhs.category() == rhs.category()
&& lhs.value() ==
639 rhs.value()
</code>.
</p>
640 <p><i>Throws:
</i>Nothing.
</p>
642 <pre>bool operator==( const error_code
& code, const error_condition
& condition );
643 bool operator==( const error_condition
& condition, const error_code
& code );
</pre>
645 <p><i>Returns:
</i> <code>code.category().equivalent( code.value(), condition )
<br>
646 || condition.category().equivalent( code, condition.value() )
</code>.
</p>
647 <p><i>Throws:
</i>Nothing.
</p>
649 <pre>bool operator==( const error_condition
& lhs, const error_condition
& rhs );
</pre>
651 <p><i>Returns:
</i> <code>lhs.category() == rhs.category()
&& lhs.value() ==
652 rhs.value()
</code>.
</p>
653 <p><i>Throws:
</i>Nothing.
</p>
655 <pre>bool operator!=( const error_code
& lhs, const error_code
& rhs );
</pre>
657 <p><i>Returns:
</i> <code>!(lhs == rhs )
</code>.
</p>
658 <p><i>Throws:
</i>Nothing.
</p>
660 <pre>bool operator!=( const error_code
& code, const error_condition
& condition );
661 bool operator!=( const error_condition
& condition, const error_code
& code );
</pre>
663 <p><i>Returns:
</i><code> !( code ==
condition )
</code>.
</p>
664 <p><i>Throws:
</i>Nothing.
</p>
666 <pre>bool operator!=( const error_condition
& lhs, const error_condition
& rhs );
</pre>
668 <p><i>Returns:
</i> <code>!(lhs == rhs )
</code>.
</p>
669 <p><i>Throws:
</i>Nothing.
</p>
671 <pre>bool operator
<( const error_code
& lhs, const error_code
& rhs );
</pre>
673 <p><i>Returns:
</i> <code>lhs.category()
< rhs.category()
<br>
674 || (lhs.category() == rhs.category()
&& lhs.value()
< rhs.value())
</code>.
</p>
675 <p><i>Throws:
</i>Nothing.
</p>
677 <pre>bool operator
<( const error_condition
& lhs, const error_condition
& rhs );
</pre>
679 <p><i>Returns:
</i> <code>lhs.category()
< rhs.category()
<br>
680 || (lhs.category() == rhs.category()
&& lhs.value()
< rhs.value())
</code>.
</p>
681 <p><i>Throws:
</i>Nothing.
</p>
683 <pre>error_code make_error_code( errc::errc_t e );
</pre>
685 <p><i>Returns:
</i> <code>error_code( e, generic_category)
</code>.
</p>
687 <pre>error_condition make_error_condition( errc::errc_t e );
</pre>
689 <p><i>Returns:
</i> <code>error_condition( e, generic_category)
</code>.
</p>
692 <pre>template
<class charT, class traits
>
693 std::basic_ostream
<charT,traits
>&
694 operator
<<( basic_ostream
<charT,traits
>& os, const error_code
& ec );
</pre>
696 <p><i>Effects:
</i> <code>os
<< ec.category().name()
<< ':'
<< ec.value()
</code>.
</p>
697 <p><i>Returns:
</i> <code>os
</code>.
</p>
699 <pre>size_t
<a name=
"hash_value">hash_value
</a>( const error_code
& ec );
</pre>
701 <p><i>Returns:
</i> A hash value representing
<code>ec
</code>.
</p>
704 <h2><a name=
"Header-system_error">Header
<boost/system/system_error.hpp
></a></h2>
706 <h3><a name=
"Class-system_error">Class
<code>
707 system_error
</code></a></h3>
708 <p>The class
<code>system_error
</code> describes an exception object used to
709 report errors that have an associated
<code><a href=
"#Class-error_code">error_code
</a></code>. Such errors typically originate from operating system or other low-level
710 application program interfaces.
</p>
716 class system_error : public std::runtime_error
719 system_error( error_code ec );
720 system_error( error_code ec, const char * what_arg );
721 system_error( error_code ec, const std::string
& what_arg );
722 system_error( error_code::value_type ev, const error_category
& ecat,
723 const char * what_arg );
724 system_error( error_code::value_type ev, const error_category
& ecat,
725 const std::string
& what_arg );
726 system_error( error_code::value_type ev, const error_category
& ecat);
728 const error_code
& code() const throw();
729 const char * what() const throw();
734 <pre>system_error( error_code ec );
</pre>
736 <p><i>Effects:
</i> Constructs an object of class
<code>system_error
</code>.
</p>
737 <p><i>Postcondition:
</i> <code>code() == ec
<br>
738 && std::strcmp( this-
>runtime_error::what(),
"" ) ==
0</code></p>
740 <pre>system_error( error_code ec, const char * what_arg );
</pre>
742 <p><i>Effects:
</i> Constructs an object of class
<code>system_error
</code>.
</p>
743 <p><i>Postcondition:
</i> <code>code() == ec
<br>
744 && std::strcmp( this-
>runtime_error::what(), what_arg ) ==
0</code></p>
746 <pre>system_error( error_code ec, const std::string
& what_arg );
</pre>
748 <p><i>Effects:
</i> Constructs an object of class
<code>system_error
</code>.
</p>
749 <p><i>Postcondition:
</i> <code>code() == ec
<br>
750 && std::strcmp( this-
>runtime_error::what(), what_arg.c_str() ) ==
0</code></p>
752 <pre>system_error( error_code::value_type ev, const error_category
& ecat,
753 const char * what_arg );
</pre>
755 <p><i>Effects:
</i> Constructs an object of class
<code>system_error
</code>.
</p>
756 <p><i>Postcondition:
</i> <code>code() == error_code( ev, ecat )
<br>
757 && std::strcmp( this-
>runtime_error::what(), what_arg ) ==
0</code></p>
759 <pre>system_error( error_code::value_type ev, const error_category
& ecat,
760 const std::string
& what_arg );
</pre>
762 <p><i>Effects:
</i> Constructs an object of class
<code>system_error
</code>.
</p>
763 <p><i>Postcondition:
</i> <code>code() == error_code( ev, ecat )
<br>
764 && std::strcmp( this-
>runtime_error::what(), what_arg.c_str() ) ==
0</code></p>
766 <pre>system_error( error_code::value_type ev, const error_category
& ecat );
</pre>
768 <p><i>Effects:
</i> Constructs an object of class
<code>system_error
</code>.
</p>
769 <p><i>Postcondition:
</i> <code>code() == error_code( ev, ecat )
<br>
770 && std::strcmp( this-
>runtime_error::what(),
"" ) ==
0</code></p>
772 <pre>const error_code
& code() const;
</pre>
774 <p><i>Returns:
</i> <code>ec
</code> or
<code>error_code( ev, ecat )
</code>, from
775 the constructor, as appropriate.
</p>
777 <pre>const char * what() const;
</pre>
779 <p><i>Returns:
</i>A string incorporating
<code>
780 this-
>runtime_error::what()
</code> and
<code>
781 code.message()
</code>.
</p>
786 <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%B %d, %Y" startspan -->October
05,
2008<!--webbot bot="Timestamp" endspan i-checksum="30983" --> </font>
789 <p>© Copyright Beman Dawes,
2006,
2007,
2008</p>
791 <p>Distributed under the Boost Software License, Version
1.0. See
792 <a href=
"http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt
</a></p>