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
+ \tcode {packaged_task(allocator_arg, allocator<int>(), std::forward<F>(f))}.
11903
+ \end {itemdescr }
11904
+
11905
+ \indexlibraryctor {packaged_task}%
11906
+ \begin {itemdecl }
11907
+ template<class F, class Allocator>
11908
+ explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f);
11909
+ \end {itemdecl }
11910
+
11913
11911
\begin {itemdescr }
11914
11912
\pnum
11915
11913
\constraints
@@ -11920,17 +11918,27 @@
11920
11918
\mandates
11921
11919
\tcode {is_invocable_r_v<R, decay_t<F>\& , ArgTypes...>} is \tcode {true}.
11922
11920
11921
+ \pnum
11922
+ \expects
11923
+ \tcode {Allocator} meets the \oldconcept {Allocator} requirements\iref {allocator.requirements.general }.
11924
+
11923
11925
\pnum
11924
11926
\effects
11927
+ Let \tcode {A2} be
11928
+ \tcode {allocator_traits<Allocator>::rebind_alloc<\unspec >}
11929
+ and let \tcode {a2} be an object of type \tcode {A2} initialized with
11930
+ \tcode {A2(a)}.
11925
11931
Constructs a new \tcode {packaged_task} object with
11926
11932
a stored task of type \tcode {decay_t<F>} and a shared state.
11927
11933
Initializes the object's stored task with \tcode {std::forward<F>(f)}.
11934
+ Uses \tcode {a2} to allocate storage for the shared state and stores a copy
11935
+ of \tcode {a2} in the shared state.
11928
11936
11929
11937
\pnum
11930
11938
\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 .
11939
+ Any exceptions thrown by the initialization of the stored task.
11940
+ If storage for the shared state cannot be allocated, any exception thrown by
11941
+ \tcode {A2::allocate} .
11934
11942
\end {itemdescr }
11935
11943
11936
11944
\indexlibraryctor {packaged_task}%
12140
12148
\begin {itemdescr }
12141
12149
\pnum
12142
12150
\effects
12143
- As if \tcode {*this = packaged_task(std::move(f))}, where
12151
+ Equivalent to:
12152
+ \begin {codeblock }
12153
+ if (!valid())
12154
+ throw future_error(future_errc::no_state);
12155
+ *this = packaged_task(allocator_arg, a, std::move(f));
12156
+ \end {codeblock }
12157
+ where
12144
12158
\tcode {f} is the task stored in
12145
- \tcode {*this}.
12159
+ \tcode {*this}
12160
+ and \tcode {a} is the allocator stored in the shared state.
12146
12161
\begin {note }
12147
12162
This constructs a new shared state for \tcode {*this}. The
12148
12163
old state is abandoned\iref {futures.state }.
12151
12166
\pnum
12152
12167
\throws
12153
12168
\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.
12169
+ \item Any exception thrown by the \tcode {packaged_task} constructor.
12157
12170
\item \tcode {future_error} with an error condition of \tcode {no_state} if \tcode {*this}
12158
12171
has no shared state.
12159
12172
\end {itemize }
0 commit comments