10724
10724
void set_value_at_thread_exit(@\seebelow@ );
10725
10725
void set_exception_at_thread_exit(exception_ptr p);
10726
10726
};
10727
-
10728
- template<class R, class Alloc>
10729
- struct uses_allocator<promise<R>, Alloc>;
10730
10727
}
10731
10728
\end {codeblock }
10732
10729
10746
10743
they acquire a single mutex associated with the promise object while updating the
10747
10744
promise object.
10748
10745
10749
- \indexlibrarymember {uses_allocator}{promise}%
10750
- \begin {itemdecl }
10751
- template<class R, class Alloc>
10752
- struct uses_allocator<promise<R>, Alloc>
10753
- : true_type { };
10754
- \end {itemdecl }
10755
-
10756
- \begin {itemdescr }
10757
- \pnum
10758
- \expects
10759
- \tcode {Alloc} meets
10760
- the \oldconcept {Allocator} requirements\iref {allocator.requirements.general }.
10761
- \end {itemdescr }
10762
-
10763
10746
\indexlibraryctor {promise}%
10764
10747
\begin {itemdecl }
10765
10748
promise();
11861
11844
packaged_task() noexcept;
11862
11845
template<class F>
11863
11846
explicit packaged_task(F&& f);
11847
+ template<class F, class Allocator>
11848
+ explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f);
11864
11849
~packaged_task();
11865
11850
11866
11851
// no copy
11910
11895
explicit packaged_task(F&& f);
11911
11896
\end {itemdecl }
11912
11897
11898
+ \begin {itemdescr }
11899
+ \pnum
11900
+ \effects
11901
+ Equivalent to:
11902
+ \begin {codeblock }
11903
+ packaged_task(allocator_arg, allocator<int>(), std::forward<F>(f)).
11904
+ \end {codeblock }
11905
+ \end {itemdescr }
11906
+
11907
+ \indexlibraryctor {packaged_task}%
11908
+ \begin {itemdecl }
11909
+ template<class F, class Allocator>
11910
+ explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f);
11911
+ \end {itemdecl }
11912
+
11913
11913
\begin {itemdescr }
11914
11914
\pnum
11915
11915
\constraints
@@ -11920,17 +11920,27 @@
11920
11920
\mandates
11921
11921
\tcode {is_invocable_r_v<R, decay_t<F>\& , ArgTypes...>} is \tcode {true}.
11922
11922
11923
+ \pnum
11924
+ \expects
11925
+ \tcode {Allocator} meets the \oldconcept {Allocator} requirements\iref {allocator.requirements.general }.
11926
+
11923
11927
\pnum
11924
11928
\effects
11929
+ Let \tcode {A2} be
11930
+ \tcode {allocator_traits<Allocator>::rebind_alloc<\unspec >}
11931
+ and let \tcode {a2} be an object of type \tcode {A2} initialized with
11932
+ \tcode {A2(a)}.
11925
11933
Constructs a new \tcode {packaged_task} object with
11926
11934
a stored task of type \tcode {decay_t<F>} and a shared state.
11927
11935
Initializes the object's stored task with \tcode {std::forward<F>(f)}.
11936
+ Uses \tcode {a2} to allocate storage for the shared state and stores a copy
11937
+ of \tcode {a2} in the shared state.
11928
11938
11929
11939
\pnum
11930
11940
\throws
11931
- Any exceptions thrown by the copy or move constructor of \tcode {f}, or
11932
- \tcode {bad_alloc} if memory for the internal data structures
11933
- cannot be allocated .
11941
+ Any exceptions thrown by the initialization of the stored task.
11942
+ If storage for the shared state cannot be allocated, any exception thrown by
11943
+ \tcode {A2::allocate} .
11934
11944
\end {itemdescr }
11935
11945
11936
11946
\indexlibraryctor {packaged_task}%
12140
12150
\begin {itemdescr }
12141
12151
\pnum
12142
12152
\effects
12143
- As if \tcode {*this = packaged_task(std::move(f))}, where
12153
+ Equivalent to:
12154
+ \begin {codeblock }
12155
+ if (!valid())
12156
+ throw future_error(future_errc::no_state);
12157
+ *this = packaged_task(allocator_arg, a, std::move(f));
12158
+ \end {codeblock }
12159
+ where
12144
12160
\tcode {f} is the task stored in
12145
- \tcode {*this}.
12161
+ \tcode {*this},
12162
+ and \tcode {a} is the allocator stored in the shared state.
12146
12163
\begin {note }
12147
12164
This constructs a new shared state for \tcode {*this}. The
12148
12165
old state is abandoned\iref {futures.state }.
12151
12168
\pnum
12152
12169
\throws
12153
12170
\begin {itemize }
12154
- \item \tcode {bad_alloc} if memory for the new shared state cannot be allocated.
12155
- \item Any exception thrown by the move constructor of the task stored in the shared
12156
- state.
12171
+ \item Any exception thrown by the \tcode {packaged_task} constructor.
12157
12172
\item \tcode {future_error} with an error condition of \tcode {no_state} if \tcode {*this}
12158
12173
has no shared state.
12159
12174
\end {itemize }
0 commit comments