From Jason Turner

[syserr]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp8c20fo4f/{from.md → to.md} +57 -84
tmp/tmp8c20fo4f/{from.md → to.md} RENAMED
@@ -1,13 +1,17 @@
1
  ## System error support <a id="syserr">[[syserr]]</a>
2
 
3
- This subclause describes components that the standard library and C++
4
- programs may use to report error conditions originating from the
 
 
5
  operating system or other low-level application program interfaces.
6
 
7
- Components described in this subclause shall not change the value of
8
- `errno` [[errno]]. Implementations should leave the error states
 
 
9
  provided by other libraries unchanged.
10
 
11
  ### Header `<system_error>` synopsis <a id="system.error.syn">[[system.error.syn]]</a>
12
 
13
  ``` cpp
@@ -67,22 +71,19 @@ namespace std {
67
  network_unreachable, // ENETUNREACH
68
  no_buffer_space, // ENOBUFS
69
  no_child_process, // ECHILD
70
  no_link, // ENOLINK
71
  no_lock_available, // ENOLCK
72
- no_message_available, // ENODATA
73
  no_message, // ENOMSG
74
  no_protocol_option, // ENOPROTOOPT
75
  no_space_on_device, // ENOSPC
76
- no_stream_resources, // ENOSR
77
  no_such_device_or_address, // ENXIO
78
  no_such_device, // ENODEV
79
  no_such_file_or_directory, // ENOENT
80
  no_such_process, // ESRCH
81
  not_a_directory, // ENOTDIR
82
  not_a_socket, // ENOTSOCK
83
- not_a_stream, // ENOSTR
84
  not_connected, // ENOTCONN
85
  not_enough_memory, // ENOMEM
86
  not_supported, // ENOTSUP
87
  operation_canceled, // ECANCELED
88
  operation_in_progress, // EINPROGRESS
@@ -96,11 +97,10 @@ namespace std {
96
  read_only_file_system, // EROFS
97
  resource_deadlock_would_occur, // EDEADLK
98
  resource_unavailable_try_again, // EAGAIN
99
  result_out_of_range, // ERANGE
100
  state_not_recoverable, // ENOTRECOVERABLE
101
- stream_timeout, // ETIME
102
  text_file_busy, // ETXTBSY
103
  timed_out, // ETIMEDOUT
104
  too_many_files_open_in_system, // ENFILE
105
  too_many_files_open, // EMFILE
106
  too_many_links, // EMLINK
@@ -119,11 +119,11 @@ namespace std {
119
  operator<<(basic_ostream<charT, traits>& os, const error_code& ec);
120
 
121
  // [syserr.errcondition.nonmembers], non-member functions
122
  error_condition make_error_condition(errc e) noexcept;
123
 
124
- // [syserr.compare], comparison functions
125
  bool operator==(const error_code& lhs, const error_code& rhs) noexcept;
126
  bool operator==(const error_code& lhs, const error_condition& rhs) noexcept;
127
  bool operator==(const error_condition& lhs, const error_condition& rhs) noexcept;
128
  strong_ordering operator<=>(const error_code& lhs, const error_code& rhs) noexcept;
129
  strong_ordering operator<=>(const error_condition& lhs, const error_condition& rhs) noexcept;
@@ -133,24 +133,24 @@ namespace std {
133
  template<> struct hash<error_code>;
134
  template<> struct hash<error_condition>;
135
 
136
  // [syserr], system error support
137
  template<class T>
138
- inline constexpr bool is_error_code_enum_v = is_error_code_enum<T>::value;
139
  template<class T>
140
- inline constexpr bool is_error_condition_enum_v = is_error_condition_enum<T>::value;
141
  }
142
  ```
143
 
144
- The value of each `enum errc` constant shall be the same as the value of
145
- the `<cerrno>` macro shown in the above synopsis. Whether or not the
146
  `<system_error>` implementation exposes the `<cerrno>` macros is
147
  unspecified.
148
 
149
- The `is_error_code_enum` and `is_error_condition_enum` may be
150
  specialized for program-defined types to indicate that such types are
151
- eligible for `class error_code` and `class error_condition` automatic
152
  conversions, respectively.
153
 
154
  ### Class `error_category` <a id="syserr.errcat">[[syserr.errcat]]</a>
155
 
156
  #### Overview <a id="syserr.errcat.overview">[[syserr.errcat.overview]]</a>
@@ -160,13 +160,14 @@ identify the source and encoding of a particular category of error code.
160
  Classes may be derived from `error_category` to support categories of
161
  errors in addition to those defined in this document. Such classes shall
162
  behave as specified in subclause  [[syserr.errcat]].
163
 
164
  [*Note 1*: `error_category` objects are passed by reference, and two
165
- such objects are equal if they have the same address. This means that
166
- applications using custom `error_category` types should create a single
167
- object of each such type. *end note*]
 
168
 
169
  ``` cpp
170
  namespace std {
171
  class error_category {
172
  public:
@@ -292,19 +293,20 @@ the same object.
292
  *Remarks:* The object’s `equivalent` virtual functions shall behave as
293
  specified for class `error_category`. The object’s `name` virtual
294
  function shall return a pointer to the string `"system"`. The object’s
295
  `default_error_condition` virtual function shall behave as follows:
296
 
297
- If the argument `ev` corresponds to a POSIX `errno` value `posv`, the
298
- function shall return `error_condition(posv, generic_category())`.
299
- Otherwise, the function shall return
300
- `error_condition(ev, system_category())`. What constitutes
 
301
  correspondence for any given operating system is unspecified.
302
 
303
  [*Note 1*: The number of potential system error codes is large and
304
- unbounded, and some may not correspond to any POSIX `errno` value. Thus
305
- implementations are given latitude in determining
306
  correspondence. — *end note*]
307
 
308
  ### Class `error_code` <a id="syserr.errcode">[[syserr.errcode]]</a>
309
 
310
  #### Overview <a id="syserr.errcode.overview">[[syserr.errcode.overview]]</a>
@@ -357,26 +359,32 @@ namespace std {
357
 
358
  ``` cpp
359
  error_code() noexcept;
360
  ```
361
 
362
- *Ensures:* `val_ == 0` and `cat_ == &system_category()`.
 
363
 
364
  ``` cpp
365
  error_code(int val, const error_category& cat) noexcept;
366
  ```
367
 
368
- *Ensures:* `val_ == val` and `cat_ == &cat`.
369
 
370
  ``` cpp
371
  template<class ErrorCodeEnum>
372
  error_code(ErrorCodeEnum e) noexcept;
373
  ```
374
 
375
  *Constraints:* `is_error_code_enum_v<ErrorCodeEnum>` is `true`.
376
 
377
- *Ensures:* `*this == make_error_code(e)`.
 
 
 
 
 
378
 
379
  #### Modifiers <a id="syserr.errcode.modifiers">[[syserr.errcode.modifiers]]</a>
380
 
381
  ``` cpp
382
  void assign(int val, const error_category& cat) noexcept;
@@ -389,11 +397,16 @@ template<class ErrorCodeEnum>
389
  error_code& operator=(ErrorCodeEnum e) noexcept;
390
  ```
391
 
392
  *Constraints:* `is_error_code_enum_v<ErrorCodeEnum>` is `true`.
393
 
394
- *Ensures:* `*this == make_error_code(e)`.
 
 
 
 
 
395
 
396
  *Returns:* `*this`.
397
 
398
  ``` cpp
399
  void clear() noexcept;
@@ -493,27 +506,33 @@ namespace std {
493
 
494
  ``` cpp
495
  error_condition() noexcept;
496
  ```
497
 
498
- *Ensures:* `val_ == 0` and `cat_ == &generic_category()`.
 
499
 
500
  ``` cpp
501
  error_condition(int val, const error_category& cat) noexcept;
502
  ```
503
 
504
- *Ensures:* `val_ == val` and `cat_ == &cat`.
505
 
506
  ``` cpp
507
  template<class ErrorConditionEnum>
508
  error_condition(ErrorConditionEnum e) noexcept;
509
  ```
510
 
511
  *Constraints:* `is_error_condition_enum_v<ErrorConditionEnum>` is
512
  `true`.
513
 
514
- *Ensures:* `*this == make_error_condition(e)`.
 
 
 
 
 
515
 
516
  #### Modifiers <a id="syserr.errcondition.modifiers">[[syserr.errcondition.modifiers]]</a>
517
 
518
  ``` cpp
519
  void assign(int val, const error_category& cat) noexcept;
@@ -527,11 +546,16 @@ template<class ErrorConditionEnum>
527
  ```
528
 
529
  *Constraints:* `is_error_condition_enum_v<ErrorConditionEnum>` is
530
  `true`.
531
 
532
- *Ensures:* `*this == make_error_condition(e)`.
 
 
 
 
 
533
 
534
  *Returns:* `*this`.
535
 
536
  ``` cpp
537
  void clear() noexcept;
@@ -571,11 +595,11 @@ explicit operator bool() const noexcept;
571
  error_condition make_error_condition(errc e) noexcept;
572
  ```
573
 
574
  *Returns:* `error_condition(static_cast<int>(e), generic_category())`.
575
 
576
- ### Comparison functions <a id="syserr.compare">[[syserr.compare]]</a>
577
 
578
  ``` cpp
579
  bool operator==(const error_code& lhs, const error_code& rhs) noexcept;
580
  ```
581
 
@@ -726,56 +750,5 @@ const char* what() const noexcept override;
726
  constructor.
727
 
728
  [*Note 1*: The returned NTBS might be the contents of
729
  `what_arg + ": " + code.message()`. — *end note*]
730
 
731
- <!-- Link reference definitions -->
732
- [assertions]: #assertions
733
- [assertions.assert]: #assertions.assert
734
- [bad.alloc]: support.md#bad.alloc
735
- [cassert.syn]: #cassert.syn
736
- [cerrno.syn]: #cerrno.syn
737
- [comparisons.three.way]: utilities.md#comparisons.three.way
738
- [conv]: expr.md#conv
739
- [defns.const.subexpr]: library.md#defns.const.subexpr
740
- [diagnostics]: #diagnostics
741
- [diagnostics.general]: #diagnostics.general
742
- [diagnostics.summary]: #diagnostics.summary
743
- [domain.error]: #domain.error
744
- [errno]: #errno
745
- [invalid.argument]: #invalid.argument
746
- [length.error]: #length.error
747
- [logic.error]: #logic.error
748
- [out.of.range]: #out.of.range
749
- [overflow.error]: #overflow.error
750
- [range.error]: #range.error
751
- [res.on.exception.handling]: library.md#res.on.exception.handling
752
- [runtime.error]: #runtime.error
753
- [std.exceptions]: #std.exceptions
754
- [stdexcept.syn]: #stdexcept.syn
755
- [syserr]: #syserr
756
- [syserr.compare]: #syserr.compare
757
- [syserr.errcat]: #syserr.errcat
758
- [syserr.errcat.derived]: #syserr.errcat.derived
759
- [syserr.errcat.nonvirtuals]: #syserr.errcat.nonvirtuals
760
- [syserr.errcat.objects]: #syserr.errcat.objects
761
- [syserr.errcat.overview]: #syserr.errcat.overview
762
- [syserr.errcat.virtuals]: #syserr.errcat.virtuals
763
- [syserr.errcode]: #syserr.errcode
764
- [syserr.errcode.constructors]: #syserr.errcode.constructors
765
- [syserr.errcode.modifiers]: #syserr.errcode.modifiers
766
- [syserr.errcode.nonmembers]: #syserr.errcode.nonmembers
767
- [syserr.errcode.observers]: #syserr.errcode.observers
768
- [syserr.errcode.overview]: #syserr.errcode.overview
769
- [syserr.errcondition]: #syserr.errcondition
770
- [syserr.errcondition.constructors]: #syserr.errcondition.constructors
771
- [syserr.errcondition.modifiers]: #syserr.errcondition.modifiers
772
- [syserr.errcondition.nonmembers]: #syserr.errcondition.nonmembers
773
- [syserr.errcondition.observers]: #syserr.errcondition.observers
774
- [syserr.errcondition.overview]: #syserr.errcondition.overview
775
- [syserr.hash]: #syserr.hash
776
- [syserr.syserr]: #syserr.syserr
777
- [syserr.syserr.members]: #syserr.syserr.members
778
- [syserr.syserr.overview]: #syserr.syserr.overview
779
- [system.error.syn]: #system.error.syn
780
- [underflow.error]: #underflow.error
781
- [unord.hash]: utilities.md#unord.hash
 
1
  ## System error support <a id="syserr">[[syserr]]</a>
2
 
3
+ ### General <a id="syserr.general">[[syserr.general]]</a>
4
+
5
+ Subclause [[syserr]] describes components that the standard library and
6
+ C++ programs may use to report error conditions originating from the
7
  operating system or other low-level application program interfaces.
8
 
9
+ Components described in [[syserr]] do not change the value of `errno`
10
+ [[errno]].
11
+
12
+ *Recommended practice:* Implementations should leave the error states
13
  provided by other libraries unchanged.
14
 
15
  ### Header `<system_error>` synopsis <a id="system.error.syn">[[system.error.syn]]</a>
16
 
17
  ``` cpp
 
71
  network_unreachable, // ENETUNREACH
72
  no_buffer_space, // ENOBUFS
73
  no_child_process, // ECHILD
74
  no_link, // ENOLINK
75
  no_lock_available, // ENOLCK
 
76
  no_message, // ENOMSG
77
  no_protocol_option, // ENOPROTOOPT
78
  no_space_on_device, // ENOSPC
 
79
  no_such_device_or_address, // ENXIO
80
  no_such_device, // ENODEV
81
  no_such_file_or_directory, // ENOENT
82
  no_such_process, // ESRCH
83
  not_a_directory, // ENOTDIR
84
  not_a_socket, // ENOTSOCK
 
85
  not_connected, // ENOTCONN
86
  not_enough_memory, // ENOMEM
87
  not_supported, // ENOTSUP
88
  operation_canceled, // ECANCELED
89
  operation_in_progress, // EINPROGRESS
 
97
  read_only_file_system, // EROFS
98
  resource_deadlock_would_occur, // EDEADLK
99
  resource_unavailable_try_again, // EAGAIN
100
  result_out_of_range, // ERANGE
101
  state_not_recoverable, // ENOTRECOVERABLE
 
102
  text_file_busy, // ETXTBSY
103
  timed_out, // ETIMEDOUT
104
  too_many_files_open_in_system, // ENFILE
105
  too_many_files_open, // EMFILE
106
  too_many_links, // EMLINK
 
119
  operator<<(basic_ostream<charT, traits>& os, const error_code& ec);
120
 
121
  // [syserr.errcondition.nonmembers], non-member functions
122
  error_condition make_error_condition(errc e) noexcept;
123
 
124
+ // [syserr.compare], comparison operator functions
125
  bool operator==(const error_code& lhs, const error_code& rhs) noexcept;
126
  bool operator==(const error_code& lhs, const error_condition& rhs) noexcept;
127
  bool operator==(const error_condition& lhs, const error_condition& rhs) noexcept;
128
  strong_ordering operator<=>(const error_code& lhs, const error_code& rhs) noexcept;
129
  strong_ordering operator<=>(const error_condition& lhs, const error_condition& rhs) noexcept;
 
133
  template<> struct hash<error_code>;
134
  template<> struct hash<error_condition>;
135
 
136
  // [syserr], system error support
137
  template<class T>
138
+ constexpr bool is_error_code_enum_v = is_error_code_enum<T>::value;
139
  template<class T>
140
+ constexpr bool is_error_condition_enum_v = is_error_condition_enum<T>::value;
141
  }
142
  ```
143
 
144
+ The value of each `enum errc` enumerator is the same as the value of the
145
+ `<cerrno>` macro shown in the above synopsis. Whether or not the
146
  `<system_error>` implementation exposes the `<cerrno>` macros is
147
  unspecified.
148
 
149
+ The `is_error_code_enum` and `is_error_condition_enum` templates may be
150
  specialized for program-defined types to indicate that such types are
151
+ eligible for `class error_code` and `class error_condition` implicit
152
  conversions, respectively.
153
 
154
  ### Class `error_category` <a id="syserr.errcat">[[syserr.errcat]]</a>
155
 
156
  #### Overview <a id="syserr.errcat.overview">[[syserr.errcat.overview]]</a>
 
160
  Classes may be derived from `error_category` to support categories of
161
  errors in addition to those defined in this document. Such classes shall
162
  behave as specified in subclause  [[syserr.errcat]].
163
 
164
  [*Note 1*: `error_category` objects are passed by reference, and two
165
+ such objects are equal if they have the same address. If there is more
166
+ than a single object of a custom `error_category` type, such equality
167
+ comparisons can evaluate to `false` even for objects holding the same
168
+ value. — *end note*]
169
 
170
  ``` cpp
171
  namespace std {
172
  class error_category {
173
  public:
 
293
  *Remarks:* The object’s `equivalent` virtual functions shall behave as
294
  specified for class `error_category`. The object’s `name` virtual
295
  function shall return a pointer to the string `"system"`. The object’s
296
  `default_error_condition` virtual function shall behave as follows:
297
 
298
+ If the argument `ev` is equal to 0, the function returns
299
+ `error_condition(0, generic_category())`. Otherwise, if `ev` corresponds
300
+ to a POSIX `errno` value `pxv`, the function returns
301
+ `error_condition(pxv, generic_category())`. Otherwise, the function
302
+ returns `error_condition(ev, system_category())`. What constitutes
303
  correspondence for any given operating system is unspecified.
304
 
305
  [*Note 1*: The number of potential system error codes is large and
306
+ unbounded, and some might not correspond to any POSIX `errno` value.
307
+ Thus implementations are given latitude in determining
308
  correspondence. — *end note*]
309
 
310
  ### Class `error_code` <a id="syserr.errcode">[[syserr.errcode]]</a>
311
 
312
  #### Overview <a id="syserr.errcode.overview">[[syserr.errcode.overview]]</a>
 
359
 
360
  ``` cpp
361
  error_code() noexcept;
362
  ```
363
 
364
+ *Effects:* Initializes `val_` with `0` and `cat_` with
365
+ `&system_category()`.
366
 
367
  ``` cpp
368
  error_code(int val, const error_category& cat) noexcept;
369
  ```
370
 
371
+ *Effects:* Initializes `val_` with `val` and `cat_` with `&cat`.
372
 
373
  ``` cpp
374
  template<class ErrorCodeEnum>
375
  error_code(ErrorCodeEnum e) noexcept;
376
  ```
377
 
378
  *Constraints:* `is_error_code_enum_v<ErrorCodeEnum>` is `true`.
379
 
380
+ *Effects:* Equivalent to:
381
+
382
+ ``` cpp
383
+ error_code ec = make_error_code(e);
384
+ assign(ec.value(), ec.category());
385
+ ```
386
 
387
  #### Modifiers <a id="syserr.errcode.modifiers">[[syserr.errcode.modifiers]]</a>
388
 
389
  ``` cpp
390
  void assign(int val, const error_category& cat) noexcept;
 
397
  error_code& operator=(ErrorCodeEnum e) noexcept;
398
  ```
399
 
400
  *Constraints:* `is_error_code_enum_v<ErrorCodeEnum>` is `true`.
401
 
402
+ *Effects:* Equivalent to:
403
+
404
+ ``` cpp
405
+ error_code ec = make_error_code(e);
406
+ assign(ec.value(), ec.category());
407
+ ```
408
 
409
  *Returns:* `*this`.
410
 
411
  ``` cpp
412
  void clear() noexcept;
 
506
 
507
  ``` cpp
508
  error_condition() noexcept;
509
  ```
510
 
511
+ *Effects:* Initializes `val_` with `0` and `cat_` with
512
+ `&generic_category()`.
513
 
514
  ``` cpp
515
  error_condition(int val, const error_category& cat) noexcept;
516
  ```
517
 
518
+ *Effects:* Initializes `val_` with `val` and `cat_` with `&cat`.
519
 
520
  ``` cpp
521
  template<class ErrorConditionEnum>
522
  error_condition(ErrorConditionEnum e) noexcept;
523
  ```
524
 
525
  *Constraints:* `is_error_condition_enum_v<ErrorConditionEnum>` is
526
  `true`.
527
 
528
+ *Effects:* Equivalent to:
529
+
530
+ ``` cpp
531
+ error_condition ec = make_error_condition(e);
532
+ assign(ec.value(), ec.category());
533
+ ```
534
 
535
  #### Modifiers <a id="syserr.errcondition.modifiers">[[syserr.errcondition.modifiers]]</a>
536
 
537
  ``` cpp
538
  void assign(int val, const error_category& cat) noexcept;
 
546
  ```
547
 
548
  *Constraints:* `is_error_condition_enum_v<ErrorConditionEnum>` is
549
  `true`.
550
 
551
+ *Effects:* Equivalent to:
552
+
553
+ ``` cpp
554
+ error_condition ec = make_error_condition(e);
555
+ assign(ec.value(), ec.category());
556
+ ```
557
 
558
  *Returns:* `*this`.
559
 
560
  ``` cpp
561
  void clear() noexcept;
 
595
  error_condition make_error_condition(errc e) noexcept;
596
  ```
597
 
598
  *Returns:* `error_condition(static_cast<int>(e), generic_category())`.
599
 
600
+ ### Comparison operator functions <a id="syserr.compare">[[syserr.compare]]</a>
601
 
602
  ``` cpp
603
  bool operator==(const error_code& lhs, const error_code& rhs) noexcept;
604
  ```
605
 
 
750
  constructor.
751
 
752
  [*Note 1*: The returned NTBS might be the contents of
753
  `what_arg + ": " + code.message()`. — *end note*]
754