10730
10730
void set_value_at_thread_exit(@\seebelow@ );
10731
10731
void set_exception_at_thread_exit(exception_ptr p);
10732
10732
};
10733
-
10734
- template<class R, class Alloc>
10735
- struct uses_allocator<promise<R>, Alloc>;
10736
10733
}
10737
10734
\end {codeblock }
10738
10735
10752
10749
they acquire a single mutex associated with the promise object while updating the
10753
10750
promise object.
10754
10751
10755
- \indexlibrarymember {uses_allocator}{promise}%
10756
- \begin {itemdecl }
10757
- template<class R, class Alloc>
10758
- struct uses_allocator<promise<R>, Alloc>
10759
- : true_type { };
10760
- \end {itemdecl }
10761
-
10762
- \begin {itemdescr }
10763
- \pnum
10764
- \expects
10765
- \tcode {Alloc} meets
10766
- the \oldconcept {Allocator} requirements\iref {allocator.requirements.general }.
10767
- \end {itemdescr }
10768
-
10769
10752
\indexlibraryctor {promise}%
10770
10753
\begin {itemdecl }
10771
10754
promise();
11867
11850
packaged_task() noexcept;
11868
11851
template<class F>
11869
11852
explicit packaged_task(F&& f);
11853
+ template<class F, class Allocator>
11854
+ explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f);
11870
11855
~packaged_task();
11871
11856
11872
11857
// no copy
11916
11901
explicit packaged_task(F&& f);
11917
11902
\end {itemdecl }
11918
11903
11904
+ \begin {itemdescr }
11905
+ \pnum
11906
+ \effects
11907
+ Equivalent to
11908
+ \tcode {packaged_task(allocator_arg, allocator<int>(), std::forward<F>(f))}.
11909
+ \end {itemdescr }
11910
+
11911
+ \indexlibraryctor {packaged_task}%
11912
+ \begin {itemdecl }
11913
+ template<class F, class Allocator>
11914
+ explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f);
11915
+ \end {itemdecl }
11916
+
11919
11917
\begin {itemdescr }
11920
11918
\pnum
11921
11919
\constraints
@@ -11926,17 +11924,27 @@
11926
11924
\mandates
11927
11925
\tcode {is_invocable_r_v<R, decay_t<F>\& , ArgTypes...>} is \tcode {true}.
11928
11926
11927
+ \pnum
11928
+ \expects
11929
+ \tcode {Allocator} meets the \oldconcept {Allocator} requirements\iref {allocator.requirements.general }.
11930
+
11929
11931
\pnum
11930
11932
\effects
11933
+ Let \tcode {A2} be
11934
+ \tcode {allocator_traits<Allocator>::rebind_alloc<\unspec >}
11935
+ and let \tcode {a2} be an object of type \tcode {A2} initialized with
11936
+ \tcode {A2(a)}.
11931
11937
Constructs a new \tcode {packaged_task} object with
11932
11938
a stored task of type \tcode {decay_t<F>} and a shared state.
11933
11939
Initializes the object's stored task with \tcode {std::forward<F>(f)}.
11940
+ Uses \tcode {a2} to allocate storage for the shared state and stores a copy
11941
+ of \tcode {a2} in the shared state.
11934
11942
11935
11943
\pnum
11936
11944
\throws
11937
- Any exceptions thrown by the copy or move constructor of \tcode {f}, or
11938
- \tcode {bad_alloc} if memory for the internal data structures
11939
- cannot be allocated .
11945
+ Any exceptions thrown by the initialization of the stored task.
11946
+ If storage for the shared state cannot be allocated, any exception thrown by
11947
+ \tcode {A2::allocate} .
11940
11948
\end {itemdescr }
11941
11949
11942
11950
\indexlibraryctor {packaged_task}%
12146
12154
\begin {itemdescr }
12147
12155
\pnum
12148
12156
\effects
12149
- As if \tcode {*this = packaged_task(std::move(f))}, where
12157
+ Equivalent to:
12158
+ \begin {codeblock }
12159
+ if (!valid()) {
12160
+ throw future_error(future_errc::no_state);
12161
+ }
12162
+ *this = packaged_task(allocator_arg, a, std::move(f));
12163
+ \end {codeblock }
12164
+ where
12150
12165
\tcode {f} is the task stored in
12151
- \tcode {*this}.
12166
+ \tcode {*this} and \tcode {a} is the allocator stored in the shared state .
12152
12167
\begin {note }
12153
12168
This constructs a new shared state for \tcode {*this}. The
12154
12169
old state is abandoned\iref {futures.state }.
12157
12172
\pnum
12158
12173
\throws
12159
12174
\begin {itemize }
12160
- \item \tcode {bad_alloc} if memory for the new shared state cannot be allocated.
12161
- \item Any exception thrown by the move constructor of the task stored in the shared
12162
- state.
12175
+ \item Any exception thrown by the \tcode {packaged_task} constructor.
12163
12176
\item \tcode {future_error} with an error condition of \tcode {no_state} if \tcode {*this}
12164
12177
has no shared state.
12165
12178
\end {itemize }
0 commit comments