29 : contains_(
t.contains_) {
30 if (contains_ == Contains::VALUE) {
44 contains_ = Contains::VALUE;
46 }
else if (
t.hasException()) {
54 std::is_nothrow_move_constructible<
T>::
value) {
61 if (
t.contains_ == Contains::VALUE) {
67 contains_ =
t.contains_;
77 "T must be copyable for Try<T> to be copyable");
78 contains_ =
t.contains_;
79 if (contains_ == Contains::VALUE) {
80 new (&value_)
T(
t.value_);
91 "T must be copyable for Try<T> to be copyable");
99 if (
t.contains_ == Contains::VALUE) {
100 new (&value_)
T(
t.value_);
105 contains_ =
t.contains_;
112 if (
LIKELY(contains_ == Contains::VALUE)) {
115 e_.~exception_wrapper();
119 template <
typename T>
120 template <
typename...
Args>
124 new (&value_)
T(static_cast<Args&&>(args)...);
125 contains_ = Contains::VALUE;
129 template <
typename T>
130 template <
typename...
Args>
134 new (&e_) exception_wrapper(static_cast<Args&&>(args)...);
166 case Contains::VALUE:
169 e_.throw_exception();
171 throw_exception<UsingUninitializedTry>();
178 if (
LIKELY(oldContains == Contains::VALUE)) {
181 e_.~exception_wrapper();
186 if (
t.hasException()) {
187 if (hasException()) {
194 if (hasException()) {
202 template <
typename...
Args>
208 new (&
e_) exception_wrapper(static_cast<Args&&>(args)...);
219 template <
typename F>
220 typename std::enable_if<
221 !std::is_same<invoke_result_t<F>,
void>
::value,
227 }
catch (std::exception& e) {
234 template <
typename F>
241 }
catch (std::exception& e) {
248 template <
typename T,
typename...
Args>
251 return std::addressof(t.
emplace(static_cast<Args&&>(args)...));
252 }
catch (
const std::exception& ex) {
265 template <
typename T,
typename Func>
269 "Unable to initialise a value of type T with the result of 'func'");
271 return std::addressof(t.
emplace(static_cast<Func&&>(func)()));
272 }
catch (
const std::exception& ex) {
281 template <
typename Func>
285 "Func returns non-void. Cannot be used to emplace Try<void>");
287 static_cast<Func&&
>(func)();
290 }
catch (
const std::exception& ex) {
299 namespace try_detail {
304 template <
typename Type>
306 template <
template <
typename...>
class TupleType,
typename... Types>
308 using type = TupleType<Types...>;
311 template <std::size_t... Indices,
typename Tuple>
315 return ReturnType{(get<Indices>(std::forward<Tuple>(instance)).value())...};
319 template <
typename Tuple>
T * tryEmplace(Try< T > &t, Args &&...args) noexcept
typename invoke_result< F, Args... >::type invoke_result_t
Try & operator=(Try< T > &&t) noexcept(std::is_nothrow_move_constructible< T >::value)
T & emplace(Args &&...args) noexcept(std::is_nothrow_constructible< T, Args &&... >::value)
constexpr detail::Map< Move > move
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
—— Concurrent Priority Queue Implementation ——
requires E e noexcept(noexcept(s.error(std::move(e))))
T * tryEmplaceWith(Try< T > &t, Func &&func) noexcept
bool hasException() const
make_integer_sequence< std::size_t, Size > make_index_sequence
exception_wrapper & emplaceException(Args &&...args) noexcept(std::is_nothrow_constructible< exception_wrapper, Args &&... >::value)
static const char *const value
void throw_exception() const
T exchange(T &obj, U &&new_value)
auto unwrapTryTupleImpl(folly::index_sequence< Indices... >, Tuple &&instance)
void throwIfFailed() const
std::enable_if< !std::is_same< invoke_result_t< F >, void >::value, Try< invoke_result_t< F > > >::type makeTryWith(F &&f)
TupleType< Types... > type
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
exception_wrapper & emplaceException(Args &&...args) noexcept(std::is_nothrow_constructible< exception_wrapper, Args &&... >::value)
PUSHMI_INLINE_VAR constexpr detail::get_fn< T > get
auto unwrapTryTuple(Tuple &&instance)