-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathexceptions.html
126 lines (107 loc) · 4.89 KB
/
exceptions.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<cxx-clause id="parallel.exceptions">
<h1>Parallel exceptions</h1>
<cxx-section id="parallel.exceptions.behavior">
<h1>Exception reporting behavior</h1>
<p>
During the execution of a standard parallel algorithm,
if temporary memory resources are required and none are available,
the algorithm throws a <code>std::bad_alloc</code> exception.
</p>
<p>
During the execution of a standard parallel algorithm, if the invocation of an element access function
exits via an uncaught exception, the behavior of the program is determined by the type of
execution policy used to invoke the algorithm:
<ul>
<li>
If the execution policy object is of type <code><del>class </del>parallel_vector_execution_policy</code><ins>, <code>unsequenced_policy</code>, or <code>vector_policy</code></ins>,
<code>std::terminate</code> shall be called.
</li>
<li>
If the execution policy object is of type <code>sequential_execution_policy</code> or
<code>parallel_execution_policy</code>, the execution of the algorithm exits via an
exception. The exception shall be an <code>exception_list</code> containing all uncaught exceptions thrown during
the invocations of element access functions, or optionally the uncaught exception if there was only one.<pre>
</pre>
<cxx-note>
For example, when <code>for_each</code> is executed sequentially,
if an invocation of the user-provided function object throws an exception, <code>for_each</code> can exit via the uncaught exception, or throw an <code>exception_list</code> containing the original exception.
</cxx-note><pre>
</pre>
<cxx-note>
These guarantees imply that, unless the algorithm has failed to allocate memory and
exits via <code>std::bad_alloc</code>, all exceptions thrown during the execution of
the algorithm are communicated to the caller. It is unspecified whether an algorithm implementation will "forge ahead" after
encountering and capturing a user exception.
</cxx-note><pre>
</pre>
<cxx-note>
The algorithm may exit via the <code>std::bad_alloc</code> exception even if one or more
user-provided function objects have exited via an exception. For example, this can happen when an algorithm fails to allocate memory while
creating or adding elements to the <code>exception_list</code> object.
</cxx-note>
</li>
<li>
If the execution policy object is of any other type, the behavior is implementation-defined.
</li>
</ul>
</p>
</cxx-section>
<cxx-section id="parallel.exceptions.synopsis">
<h1>Header <code><experimental/exception_list></code> synopsis</h1>
<pre>
namespace std {
namespace experimental {
namespace parallel {
inline namespace v2 {
class exception_list : public exception
{
public:
typedef <em>unspecified</em> iterator;
size_t size() const noexcept;
iterator begin() const noexcept;
iterator end() const noexcept;
const char* what() const noexcept override;
};
}
}
}
}
</pre>
<p>
The class <code>exception_list</code> owns a sequence of <code>exception_ptr</code> objects. The parallel
algorithms may use the <code>exception_list</code> to communicate uncaught exceptions encountered during parallel execution to the
caller of the algorithm.
</p>
<p>
The type <code>exception_list::iterator</code> shall fulfill the requirements of
<code>ForwardIterator</code>.
</p>
<cxx-function>
<cxx-signature>size_t size() const noexcept;</cxx-signature>
<cxx-returns>
The number of <code>exception_ptr</code> objects contained within the <code>exception_list</code>.
</cxx-returns>
<cxx-complexity>
Constant time.
</cxx-complexity>
</cxx-function>
<cxx-function>
<cxx-signature>iterator begin() const noexcept;</cxx-signature>
<cxx-returns>
An iterator referring to the first <code>exception_ptr</code> object contained within the <code>exception_list</code>.
</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>iterator end() const noexcept;</cxx-signature>
<cxx-returns>
An iterator that is past the end of the owned sequence.
</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>const char* what() const noexcept override;</cxx-signature>
<cxx-returns>
An implementation-defined NTBS.
</cxx-returns>
</cxx-function>
</cxx-section>
</cxx-clause>