19#ifndef TL_EXPECTED_HPP
20#define TL_EXPECTED_HPP
33#define TL_EXPECTED_VERSION_MAJOR 1
34#define TL_EXPECTED_VERSION_MINOR 1
35#define TL_EXPECTED_VERSION_PATCH 0
37#include <QtCore/private/qglobal_p.h>
38#include <QtCore/qassert.h>
39#include <QtCore/qtconfiginclude.h>
40#include <QtCore/qtconfigmacros.h>
47#define TL_ASSERT Q_ASSERT
49#if defined(__EXCEPTIONS
) || defined(_CPPUNWIND)
50#define TL_EXPECTED_EXCEPTIONS_ENABLED
53#if defined(TL_EXPECTED_EXCEPTIONS_ENABLED
) && defined(QT_NO_EXCEPTIONS)
54# undef TL_EXPECTED_EXCEPTIONS_ENABLED
57#if (defined(_MSC_VER) && _MSC_VER == 1900
)
58#define TL_EXPECTED_MSVC2015
59#define TL_EXPECTED_MSVC2015_CONSTEXPR
61#define TL_EXPECTED_MSVC2015_CONSTEXPR constexpr
64#if (defined(__GNUC__
) && __GNUC__
== 4
&& __GNUC_MINOR__
<= 9
&&
66#define TL_EXPECTED_GCC49
69#if (defined(__GNUC__
) && __GNUC__
== 5
&& __GNUC_MINOR__
<= 4
&&
71#define TL_EXPECTED_GCC54
74#if (defined(__GNUC__
) && __GNUC__
== 5
&& __GNUC_MINOR__
<= 5
&&
76#define TL_EXPECTED_GCC55
81#if (TL_CPLUSPLUS > 201103L
) && !defined(TL_EXPECTED_GCC49)
83#define TL_ASSERT(x) assert(x)
89#if (defined(__GNUC__
) && __GNUC__
== 4
&& __GNUC_MINOR__
<= 9
&&
93#define TL_EXPECTED_NO_CONSTRR
95#define TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T)
96 std::has_trivial_copy_constructor<T>
97#define TL_EXPECTED_IS_TRIVIALLY_COPY_ASSIGNABLE(T)
98 std::has_trivial_copy_assign<T>
101#define TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(T)
102 std::is_trivially_destructible<T>
106#elif (defined(__GNUC__
) && __GNUC__
< 8
&& !defined(__clang__
))
107#ifndef TL_GCC_LESS_8_TRIVIALLY_COPY_CONSTRUCTIBLE_MUTEX
108#define TL_GCC_LESS_8_TRIVIALLY_COPY_CONSTRUCTIBLE_MUTEX
113struct is_trivially_copy_constructible
114 : std::is_trivially_copy_constructible<T> {};
115#ifdef _GLIBCXX_VECTOR
116template <
class T,
class A>
117struct is_trivially_copy_constructible<std::vector<T, A>> : std::false_type {};
124#define TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T)
125 q23::detail::is_trivially_copy_constructible<T>
126#define TL_EXPECTED_IS_TRIVIALLY_COPY_ASSIGNABLE(T)
127 std::is_trivially_copy_assignable<T>
128#define TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(T)
129 std::is_trivially_destructible<T>
131#define TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T)
132 std::is_trivially_copy_constructible<T>
133#define TL_EXPECTED_IS_TRIVIALLY_COPY_ASSIGNABLE(T)
134 std::is_trivially_copy_assignable<T>
135#define TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(T)
136 std::is_trivially_destructible<T>
140#define TL_CPLUSPLUS _MSVC_LANG
142#define TL_CPLUSPLUS __cplusplus
146#define TL_EXPECTED_CXX14
149#ifdef TL_EXPECTED_GCC49
150#define TL_EXPECTED_GCC49_CONSTEXPR
152#define TL_EXPECTED_GCC49_CONSTEXPR constexpr
155#if (TL_CPLUSPLUS == 201103L
|| defined(TL_EXPECTED_MSVC2015) ||
156 defined(TL_EXPECTED_GCC49))
157#define TL_EXPECTED_11_CONSTEXPR
159#define TL_EXPECTED_11_CONSTEXPR constexpr
164template <
class T,
class E>
class expected;
166#ifndef TL_MONOSTATE_INPLACE_MUTEX
167#define TL_MONOSTATE_INPLACE_MUTEX
178 static_assert(!
std::is_same<E,
void>::value,
"E must not be void");
185 template <
class... Args,
typename std::enable_if<std::is_constructible<
186 E, Args &&...>::value>::type * =
nullptr>
188 : m_val(
std::forward<Args>(args)...) {}
191 class U,
class... Args,
192 typename std::enable_if<std::is_constructible<
193 E, std::initializer_list<U> &, Args &&...>::value>::type * =
nullptr>
196 : m_val(l,
std::forward<Args>(args)...) {}
198 constexpr const E &
error()
const & {
return m_val; }
201 constexpr const E &&
error()
const && {
return std::move(m_val); }
207#ifdef __cpp_deduction_guides
208template <
class E> unexpected(E) ->
unexpected<E>;
213 return lhs.error() == rhs.error();
217 return lhs.error() != rhs.error();
221 return lhs.error() < rhs.error();
225 return lhs.error() <= rhs.error();
229 return lhs.error() > rhs.error();
233 return lhs.error() >= rhs.error();
249#ifdef TL_EXPECTED_EXCEPTIONS_ENABLED
250 throw std::forward<E>(e);
261#ifndef TL_TRAITS_MUTEX
262#define TL_TRAITS_MUTEX
268template <
bool E,
class T =
void>
270template <
bool B,
class T,
class F>
276template <
class B,
class... Bs>
278 :
std::conditional<
bool(B::value),
conjunction<Bs...>, B>::type {};
280#if defined(_LIBCPP_VERSION) && __cplusplus
== 201103L
281#define TL_TRAITS_LIBCXX_MEM_FN_WORKAROUND
287#ifdef TL_TRAITS_LIBCXX_MEM_FN_WORKAROUND
290template <
class T,
class Ret,
class...
Args>
293template <
class T,
class Ret,
class...
Args>
296template <
class T,
class Ret,
class...
Args>
299template <
class T,
class Ret,
class...
Args>
302template <
class T,
class Ret,
class...
Args>
305template <
class T,
class Ret,
class...
Args>
317 typename Fn,
typename... Args,
318#ifdef TL_TRAITS_LIBCXX_MEM_FN_WORKAROUND
323constexpr auto invoke(Fn &&f, Args &&...args)
noexcept(
325 ->
decltype(
std::mem_fn(f)(
std::forward<Args>(args)...)) {
326 return std::mem_fn(f)(
std::forward<Args>(args)...);
329template <
typename Fn,
typename... Args,
331constexpr auto invoke(Fn &&f, Args &&...args)
noexcept(
333 ->
decltype(
std::forward<Fn>(f)(
std::forward<Args>(args)...)) {
334 return std::forward<Fn>(f)(
std::forward<Args>(args)...);
340template <
class F,
class... Us>
343 decltype(
detail::invoke(
std::declval<F>(),
std::declval<Us>()...),
void()),
346 decltype(
detail::invoke(
std::declval<F>(),
std::declval<Us>()...));
349template <
class F,
class... Us>
352template <
class F,
class...
Us>
355#if defined(_MSC_VER) && _MSC_VER <= 1900
368template <
class T,
std::size_t N>
tag swap(T (&a)[N], T (&b)[N]);
373template <
class T,
class U,
374 class =
decltype(swap(
std::declval<T &>(),
std::declval<U &>()))>
379template <
class T,
class U>
380std::is_same<
decltype(swap(
std::declval<T &>(),
std::declval<U &>())),
tag>
389template <
class T,
std::size_t N>
392template <
class T,
class U>
397template <
class T,
class U = T>
406template <
class T,
std::size_t N>
415template <
class T,
class U = T>
429template <
class T,
class E>
433template <
class T,
class E,
class U>
440template <
class T,
class E,
class U,
class G,
class UR,
class GR>
453template <
class T,
class U>
482template <
class T,
class E,
bool =
std::is_trivially_destructible<T>::value,
483 bool =
std::is_trivially_destructible<E>::value>
488 template <
class... Args,
489 detail::enable_if_t<std::is_constructible<T, Args &&...>::value> * =
494 template <
class U,
class... Args,
495 detail::enable_if_t<std::is_constructible<
496 T, std::initializer_list<U> &, Args &&...>::value> * =
nullptr>
500 template <
class... Args,
501 detail::enable_if_t<std::is_constructible<E, Args &&...>::value> * =
506 template <
class U,
class... Args,
507 detail::enable_if_t<std::is_constructible<
508 E, std::initializer_list<U> &, Args &&...>::value> * =
nullptr>
510 std::initializer_list<U> il,
535 template <
class... Args,
536 detail::enable_if_t<std::is_constructible<T, Args &&...>::value> * =
541 template <
class U,
class... Args,
542 detail::enable_if_t<std::is_constructible<
543 T, std::initializer_list<U> &, Args &&...>::value> * =
nullptr>
547 template <
class... Args,
548 detail::enable_if_t<std::is_constructible<E, Args &&...>::value> * =
553 template <
class U,
class... Args,
554 detail::enable_if_t<std::is_constructible<
555 E, std::initializer_list<U> &, Args &&...>::value> * =
nullptr>
557 std::initializer_list<U> il,
580 template <
class... Args,
581 detail::enable_if_t<std::is_constructible<T, Args &&...>::value> * =
586 template <
class U,
class... Args,
587 detail::enable_if_t<std::is_constructible<
588 T, std::initializer_list<U> &, Args &&...>::value> * =
nullptr>
592 template <
class... Args,
593 detail::enable_if_t<std::is_constructible<E, Args &&...>::value> * =
598 template <
class U,
class... Args,
599 detail::enable_if_t<std::is_constructible<
600 E, std::initializer_list<U> &, Args &&...>::value> * =
nullptr>
602 std::initializer_list<U> il,
629 template <
class... Args,
630 detail::enable_if_t<std::is_constructible<T, Args &&...>::value> * =
635 template <
class U,
class... Args,
636 detail::enable_if_t<std::is_constructible<
637 T, std::initializer_list<U> &, Args &&...>::value> * =
nullptr>
641 template <
class... Args,
642 detail::enable_if_t<std::is_constructible<E, Args &&...>::value> * =
647 template <
class U,
class... Args,
648 detail::enable_if_t<std::is_constructible<
649 E, std::initializer_list<U> &, Args &&...>::value> * =
nullptr>
651 std::initializer_list<U> il,
686 template <
class... Args,
687 detail::enable_if_t<std::is_constructible<E, Args &&...>::value> * =
692 template <
class U,
class... Args,
693 detail::enable_if_t<std::is_constructible<
694 E, std::initializer_list<U> &, Args &&...>::value> * =
nullptr>
696 std::initializer_list<U> il,
720 template <
class... Args,
721 detail::enable_if_t<std::is_constructible<E, Args &&...>::value> * =
726 template <
class U,
class... Args,
727 detail::enable_if_t<std::is_constructible<
728 E, std::initializer_list<U> &, Args &&...>::value> * =
nullptr>
730 std::initializer_list<U> il,
753template <
class T,
class E>
757 template <
class... Args>
void construct(Args &&...args)
noexcept {
758 new (
std::addressof(
this->m_val)) T(
std::forward<Args>(args)...);
759 this->m_has_val =
true;
763 new (
std::addressof(
this->m_val)) T(
std::forward<Rhs>(rhs).get());
764 this->m_has_val =
true;
768 new (
std::addressof(
this->m_unexpect))
770 this->m_has_val =
false;
773#ifdef TL_EXPECTED_EXCEPTIONS_ENABLED
781 template <
class U = T,
782 detail::enable_if_t<std::is_nothrow_copy_constructible<U>::value>
785 if (!
this->m_has_val && rhs.m_has_val) {
787 construct(rhs.get());
795 template <
class U = T,
796 detail::enable_if_t<!std::is_nothrow_copy_constructible<U>::value &&
797 std::is_nothrow_move_constructible<U>::value>
800 if (!
this->m_has_val && rhs.m_has_val) {
803 construct(
std::move(tmp));
814 template <
class U = T,
815 detail::enable_if_t<!std::is_nothrow_copy_constructible<U>::value &&
816 !std::is_nothrow_move_constructible<U>::value>
819 if (!
this->m_has_val && rhs.m_has_val) {
820 auto tmp =
std::move(geterr());
823#ifdef TL_EXPECTED_EXCEPTIONS_ENABLED
825 construct(rhs.get());
827 geterr() =
std::move(tmp);
831 construct(rhs.get());
839 template <
class U = T,
840 detail::enable_if_t<std::is_nothrow_move_constructible<U>::value>
843 if (!
this->m_has_val && rhs.m_has_val) {
845 construct(
std::move(rhs).get());
847 assign_common(
std::move(rhs));
851 template <
class U = T,
852 detail::enable_if_t<!std::is_nothrow_move_constructible<U>::value>
855 if (!
this->m_has_val && rhs.m_has_val) {
856 auto tmp =
std::move(geterr());
858#ifdef TL_EXPECTED_EXCEPTIONS_ENABLED
860 construct(
std::move(rhs).get());
862 geterr() =
std::move(tmp);
866 construct(std::move(rhs).get());
869 assign_common(
std::move(rhs));
898 if (
this->m_has_val) {
900 get() =
std::forward<Rhs>(rhs).get();
903 construct_error(
std::forward<Rhs>(rhs).geterr());
906 if (!rhs.m_has_val) {
907 geterr() =
std::forward<Rhs>(rhs).geterr();
915 constexpr const T &
get()
const & {
return this->m_val; }
917#ifndef TL_EXPECTED_NO_CONSTRR
918 constexpr const T &&
get()
const && {
return std::move(
this->m_val); }
922 return this->m_unexpect;
926 return std::move(
this->m_unexpect);
928#ifndef TL_EXPECTED_NO_CONSTRR
930 return std::move(
this->m_unexpect);
943 template <
class... Args>
void construct()
noexcept {
this->m_has_val =
true; }
948 this->m_has_val =
true;
952 new (
std::addressof(
this->m_unexpect))
954 this->m_has_val =
false;
957 template <
class Rhs>
void assign(Rhs &&rhs)
noexcept {
958 if (!
this->m_has_val) {
963 geterr() =
std::forward<Rhs>(rhs).geterr();
966 if (!rhs.m_has_val) {
967 construct_error(
std::forward<Rhs>(rhs).geterr());
975 return this->m_unexpect;
979 return std::move(
this->m_unexpect);
981#ifndef TL_EXPECTED_NO_CONSTRR
983 return std::move(
this->m_unexpect);
994template <
class T,
class E,
1004template <
class T,
class E>
1011 if (rhs.has_value()) {
1012 this->construct_with(rhs);
1014 this->construct_error(rhs.geterr());
1028#ifndef TL_EXPECTED_GCC49
1029template <
class T,
class E,
1038template <
class T,
class E>
1048 if (rhs.has_value()) {
1049 this->construct_with(
std::move(rhs));
1051 this->construct_error(
std::move(rhs.geterr()));
1059template <
class T,
class E,
1075template <
class T,
class E>
1096#ifndef TL_EXPECTED_GCC49
1097template <
class T,
class E,
1112template <
class T,
class E>
1129 this->assign(
std::move(rhs));
1136template <
class T,
class E,
1151template <
class T,
class E>
1162template <
class T,
class E>
1173template <
class T,
class E>
1187template <
class T,
class E,
1207template <
class T,
class E>
1219template <
class T,
class E>
1231template <
class T,
class E>
1252template <
class T,
class E,
1254 std::is_default_constructible<T>::value ||
std::is_void<T>::value>
1289 virtual const char *
what()
const noexcept override {
1290 return "Bad expected access";
1293 const E &
error()
const & {
return m_val; }
1295 const E &&
error()
const && {
return std::move(m_val); }
1309template <
class T,
class E>
1314 static_assert(!
std::is_reference<T>::value,
"T must not be a reference");
1316 "T must not be in_place_t");
1318 "T must not be unexpect_t");
1321 "T must not be unexpected<E>");
1322 static_assert(!
std::is_reference<E>::value,
"E must not be a reference");
1324 T *valptr() {
return std::addressof(
this->m_val); }
1325 const T *valptr()
const {
return std::addressof(
this->m_val); }
1326 unexpected<E> *errptr() {
return std::addressof(
this->m_unexpect); }
1328 return std::addressof(
this->m_unexpect);
1331 template <
class U = T,
1332 detail::enable_if_t<!std::is_void<U>::value> * =
nullptr>
1338 template <
class U = T,
1339 detail::enable_if_t<!std::is_void<U>::value> * =
nullptr>
1340 constexpr const U &val()
const {
1343 constexpr const unexpected<E> &err()
const {
return this->m_unexpect; }
1353#if defined(TL_EXPECTED_CXX14
) && !defined(TL_EXPECTED_GCC49) &&
1354 !defined(TL_EXPECTED_GCC54) && !defined(TL_EXPECTED_GCC55)
1356 return and_then_impl(*
this,
std::forward<F>(f));
1359 return and_then_impl(
std::move(*
this),
std::forward<F>(f));
1361 template <
class F>
constexpr auto and_then(F &&f)
const & {
1362 return and_then_impl(*
this,
std::forward<F>(f));
1365#ifndef TL_EXPECTED_NO_CONSTRR
1366 template <
class F>
constexpr auto and_then(F &&f)
const && {
1367 return and_then_impl(
std::move(*
this),
std::forward<F>(f));
1390#ifndef TL_EXPECTED_NO_CONSTRR
1399#if defined(TL_EXPECTED_CXX14
) && !defined(TL_EXPECTED_GCC49) &&
1400 !defined(TL_EXPECTED_GCC54) && !defined(TL_EXPECTED_GCC55)
1402 return expected_map_impl(*
this,
std::forward<F>(f));
1405 return expected_map_impl(
std::move(*
this),
std::forward<F>(f));
1407 template <
class F>
constexpr auto map(F &&f)
const & {
1408 return expected_map_impl(*
this,
std::forward<F>(f));
1410 template <
class F>
constexpr auto map(F &&f)
const && {
1411 return expected_map_impl(
std::move(*
this),
std::forward<F>(f));
1433#ifndef TL_EXPECTED_NO_CONSTRR
1443#if defined(TL_EXPECTED_CXX14
) && !defined(TL_EXPECTED_GCC49) &&
1444 !defined(TL_EXPECTED_GCC54) && !defined(TL_EXPECTED_GCC55)
1446 return expected_map_impl(*
this,
std::forward<F>(f));
1449 return expected_map_impl(
std::move(*
this),
std::forward<F>(f));
1451 template <
class F>
constexpr auto transform(F &&f)
const & {
1452 return expected_map_impl(*
this,
std::forward<F>(f));
1454 template <
class F>
constexpr auto transform(F &&f)
const && {
1455 return expected_map_impl(
std::move(*
this),
std::forward<F>(f));
1477#ifndef TL_EXPECTED_NO_CONSTRR
1487#if defined(TL_EXPECTED_CXX14
) && !defined(TL_EXPECTED_GCC49) &&
1488 !defined(TL_EXPECTED_GCC54) && !defined(TL_EXPECTED_GCC55)
1490 return map_error_impl(*
this,
std::forward<F>(f));
1493 return map_error_impl(
std::move(*
this),
std::forward<F>(f));
1495 template <
class F>
constexpr auto map_error(F &&f)
const & {
1496 return map_error_impl(*
this,
std::forward<F>(f));
1498 template <
class F>
constexpr auto map_error(F &&f)
const && {
1499 return map_error_impl(
std::move(*
this),
std::forward<F>(f));
1521#ifndef TL_EXPECTED_NO_CONSTRR
1530#if defined(TL_EXPECTED_CXX14
) && !defined(TL_EXPECTED_GCC49) &&
1531 !defined(TL_EXPECTED_GCC54) && !defined(TL_EXPECTED_GCC55)
1533 return map_error_impl(*
this,
std::forward<F>(f));
1536 return map_error_impl(
std::move(*
this),
std::forward<F>(f));
1538 template <
class F>
constexpr auto transform_error(F &&f)
const & {
1539 return map_error_impl(*
this,
std::forward<F>(f));
1541 template <
class F>
constexpr auto transform_error(F &&f)
const && {
1542 return map_error_impl(
std::move(*
this),
std::forward<F>(f));
1564#ifndef TL_EXPECTED_NO_CONSTRR
1574 return or_else_impl(*
this,
std::forward<F>(f));
1578 return or_else_impl(
std::move(*
this),
std::forward<F>(f));
1582 return or_else_impl(*
this,
std::forward<F>(f));
1585#ifndef TL_EXPECTED_NO_CONSTRR
1587 return or_else_impl(
std::move(*
this),
std::forward<F>(f));
1596 template <
class... Args,
1597 detail::enable_if_t<std::is_constructible<T, Args &&...>::value> * =
1603 template <
class U,
class... Args,
1604 detail::enable_if_t<std::is_constructible<
1605 T, std::initializer_list<U> &, Args &&...>::value> * =
nullptr>
1610 template <
class G = E,
1611 detail::enable_if_t<std::is_constructible<E,
const G &>::value> * =
1613 detail::enable_if_t<!std::is_convertible<
const G &, E>::value> * =
1621 detail::enable_if_t<std::is_constructible<E,
const G &>::value> * =
1623 detail::enable_if_t<std::is_convertible<
const G &, E>::value> * =
nullptr>
1630 detail::enable_if_t<std::is_constructible<E, G &&>::value> * =
nullptr,
1631 detail::enable_if_t<!std::is_convertible<G &&, E>::value> * =
nullptr>
1639 detail::enable_if_t<std::is_constructible<E, G &&>::value> * =
nullptr,
1640 detail::enable_if_t<std::is_convertible<G &&, E>::value> * =
nullptr>
1646 template <
class... Args,
1647 detail::enable_if_t<std::is_constructible<E, Args &&...>::value> * =
1653 template <
class U,
class... Args,
1654 detail::enable_if_t<std::is_constructible<
1655 E, std::initializer_list<U> &, Args &&...>::value> * =
nullptr>
1661 template <
class U,
class G,
1662 detail::enable_if_t<!(std::is_convertible<U
const &, T>::value &&
1663 std::is_convertible<G
const &, E>::value)> * =
1665 detail::expected_enable_from_other<T, E, U, G,
const U &,
const G &>
1669 if (rhs.has_value()) {
1670 this->construct(*rhs);
1672 this->construct_error(rhs.error());
1676 template <
class U,
class G,
1677 detail::enable_if_t<(std::is_convertible<U
const &, T>::value &&
1678 std::is_convertible<G
const &, E>::value)> * =
1680 detail::expected_enable_from_other<T, E, U, G,
const U &,
const G &>
1684 if (rhs.has_value()) {
1685 this->construct(*rhs);
1687 this->construct_error(rhs.error());
1693 detail::enable_if_t<!(std::is_convertible<U &&, T>::value &&
1694 std::is_convertible<G &&, E>::value)> * =
nullptr,
1695 detail::expected_enable_from_other<T, E, U, G, U &&, G &&> * =
nullptr>
1698 if (rhs.has_value()) {
1699 this->construct(
std::move(*rhs));
1701 this->construct_error(
std::move(rhs.error()));
1707 detail::enable_if_t<(std::is_convertible<U &&, T>::value &&
1708 std::is_convertible<G &&, E>::value)> * =
nullptr,
1709 detail::expected_enable_from_other<T, E, U, G, U &&, G &&> * =
nullptr>
1712 if (rhs.has_value()) {
1713 this->construct(
std::move(*rhs));
1715 this->construct_error(
std::move(rhs.error()));
1721 detail::enable_if_t<!std::is_convertible<U &&, T>::value> * =
nullptr,
1722 detail::expected_enable_forward_value<T, E, U> * =
nullptr>
1728 detail::enable_if_t<std::is_convertible<U &&, T>::value> * =
nullptr,
1729 detail::expected_enable_forward_value<T, E, U> * =
nullptr>
1734 class U = T,
class G = T,
1735 detail::enable_if_t<std::is_nothrow_constructible<T, U &&>::value> * =
1737 detail::enable_if_t<!std::is_void<G>::value> * =
nullptr,
1738 detail::enable_if_t<
1739 (!std::is_same<expected<T, E>, detail::decay_t<U>>::value &&
1740 !detail::conjunction<std::is_scalar<T>,
1741 std::is_same<T, detail::decay_t<U>>>::value &&
1742 std::is_constructible<T, U>::value &&
1743 std::is_assignable<G &, U>::value &&
1744 std::is_nothrow_move_constructible<E>::value)> * =
nullptr>
1747 val() =
std::forward<U>(v);
1750 ::
new (valptr()) T(
std::forward<U>(v));
1751 this->m_has_val =
true;
1758 class U = T,
class G = T,
1759 detail::enable_if_t<!std::is_nothrow_constructible<T, U &&>::value> * =
1761 detail::enable_if_t<!std::is_void<U>::value> * =
nullptr,
1762 detail::enable_if_t<
1763 (!std::is_same<expected<T, E>, detail::decay_t<U>>::value &&
1764 !detail::conjunction<std::is_scalar<T>,
1765 std::is_same<T, detail::decay_t<U>>>::value &&
1766 std::is_constructible<T, U>::value &&
1767 std::is_assignable<G &, U>::value &&
1768 std::is_nothrow_move_constructible<E>::value)> * =
nullptr>
1771 val() =
std::forward<U>(v);
1773 auto tmp =
std::move(err());
1776#ifdef TL_EXPECTED_EXCEPTIONS_ENABLED
1778 ::
new (valptr()) T(
std::forward<U>(v));
1779 this->m_has_val =
true;
1781 err() =
std::move(tmp);
1785 ::
new (valptr()) T(std::forward<U>(v));
1786 this->m_has_val =
true;
1793 template <
class G = E,
1794 detail::enable_if_t<std::is_nothrow_copy_constructible<G>::value &&
1795 std::is_assignable<G &, G>::value> * =
nullptr>
1800 this->destroy_val();
1802 this->m_has_val =
false;
1808 template <
class G = E,
1809 detail::enable_if_t<std::is_nothrow_move_constructible<G>::value &&
1810 std::is_move_assignable<G>::value> * =
nullptr>
1813 err() =
std::move(rhs);
1815 this->destroy_val();
1817 this->m_has_val =
false;
1823 template <
class... Args, detail::enable_if_t<std::is_nothrow_constructible<
1824 T, Args &&...>::value> * =
nullptr>
1830 this->m_has_val =
true;
1832 ::
new (valptr()) T(
std::forward<Args>(args)...);
1835 template <
class... Args, detail::enable_if_t<!std::is_nothrow_constructible<
1836 T, Args &&...>::value> * =
nullptr>
1840 ::
new (valptr()) T(
std::forward<Args>(args)...);
1842 auto tmp =
std::move(err());
1845#ifdef TL_EXPECTED_EXCEPTIONS_ENABLED
1847 ::
new (valptr()) T(
std::forward<Args>(args)...);
1848 this->m_has_val =
true;
1850 err() =
std::move(tmp);
1854 ::
new (valptr()) T(std::forward<Args>(args)...);
1855 this->m_has_val =
true;
1860 template <
class U,
class... Args,
1861 detail::enable_if_t<std::is_nothrow_constructible<
1862 T, std::initializer_list<U> &, Args &&...>::value> * =
nullptr>
1865 T t(il,
std::forward<Args>(args)...);
1866 val() =
std::move(t);
1869 ::
new (valptr()) T(il,
std::forward<Args>(args)...);
1870 this->m_has_val =
true;
1874 template <
class U,
class... Args,
1875 detail::enable_if_t<!std::is_nothrow_constructible<
1876 T, std::initializer_list<U> &, Args &&...>::value> * =
nullptr>
1879 T t(il,
std::forward<Args>(args)...);
1880 val() =
std::move(t);
1882 auto tmp =
std::move(err());
1885#ifdef TL_EXPECTED_EXCEPTIONS_ENABLED
1887 ::
new (valptr()) T(il,
std::forward<Args>(args)...);
1888 this->m_has_val =
true;
1890 err() =
std::move(tmp);
1894 ::
new (valptr()) T(il, std::forward<Args>(args)...);
1895 this->m_has_val =
true;
1908 void swap_where_both_have_value(
expected & , t_is_void)
noexcept {
1912 void swap_where_both_have_value(
expected &rhs, t_is_not_void) {
1914 swap(val(), rhs.val());
1917 void swap_where_only_one_has_value(
expected &rhs, t_is_void)
noexcept(
1918 std::is_nothrow_move_constructible<E>::value) {
1921 std::swap(
this->m_has_val, rhs.m_has_val);
1924 void swap_where_only_one_has_value(
expected &rhs, t_is_not_void) {
1925 swap_where_only_one_has_value_and_t_is_not_void(
1926 rhs,
typename std::is_nothrow_move_constructible<T>::type{},
1927 typename std::is_nothrow_move_constructible<E>::type{});
1930 void swap_where_only_one_has_value_and_t_is_not_void(
1931 expected &rhs, t_is_nothrow_move_constructible,
1932 e_is_nothrow_move_constructible)
noexcept {
1933 auto temp =
std::move(val());
1937 ::
new (rhs.valptr()) T(
std::move(temp));
1938 std::swap(
this->m_has_val, rhs.m_has_val);
1941 void swap_where_only_one_has_value_and_t_is_not_void(
1942 expected &rhs, t_is_nothrow_move_constructible,
1943 move_constructing_e_can_throw) {
1944 auto temp =
std::move(val());
1946#ifdef TL_EXPECTED_EXCEPTIONS_ENABLED
1950 ::
new (rhs.valptr()) T(
std::move(temp));
1951 std::swap(
this->m_has_val, rhs.m_has_val);
1953 val() =
std::move(temp);
1957 ::
new (errptr()) unexpected_type(std::move(rhs.err()));
1958 rhs.err().~unexpected_type();
1959 ::
new (rhs.valptr()) T(std::move(temp));
1960 std::swap(
this->m_has_val, rhs.m_has_val);
1964 void swap_where_only_one_has_value_and_t_is_not_void(
1965 expected &rhs, move_constructing_t_can_throw,
1966 e_is_nothrow_move_constructible) {
1967 auto temp =
std::move(rhs.err());
1969#ifdef TL_EXPECTED_EXCEPTIONS_ENABLED
1971 ::
new (rhs.valptr()) T(
std::move(val()));
1974 std::swap(
this->m_has_val, rhs.m_has_val);
1976 rhs.err() =
std::move(temp);
1980 ::
new (rhs.valptr()) T(std::move(val()));
1982 ::
new (errptr()) unexpected_type(std::move(temp));
1983 std::swap(
this->m_has_val, rhs.m_has_val);
1988 template <
class OT = T,
class OE = E>
1999 swap_where_both_have_value(rhs,
typename std::is_void<T>::type{});
2003 swap_where_only_one_has_value(rhs,
typename std::is_void<T>::type{});
2006 swap(err(), rhs.err());
2019 template <
class U = T,
2020 detail::enable_if_t<!std::is_void<U>::value> * =
nullptr>
2025 template <
class U = T,
2026 detail::enable_if_t<!std::is_void<U>::value> * =
nullptr>
2031 template <
class U = T,
2032 detail::enable_if_t<!std::is_void<U>::value> * =
nullptr>
2035 return std::move(val());
2037 template <
class U = T,
2038 detail::enable_if_t<!std::is_void<U>::value> * =
nullptr>
2041 return std::move(val());
2044 constexpr bool has_value()
const noexcept {
return this->m_has_val; }
2045 constexpr explicit operator bool()
const noexcept {
return this->m_has_val; }
2047 template <
class U = T,
2048 detail::enable_if_t<!std::is_void<U>::value> * =
nullptr>
2054 template <
class U = T,
2055 detail::enable_if_t<!std::is_void<U>::value> * =
nullptr>
2061 template <
class U = T,
2062 detail::enable_if_t<!std::is_void<U>::value> * =
nullptr>
2066 return std::move(val());
2068 template <
class U = T,
2069 detail::enable_if_t<!std::is_void<U>::value> * =
nullptr>
2073 return std::move(val());
2078 return err().error();
2082 return err().error();
2086 return std::move(err().error());
2090 return std::move(err().error());
2093 template <
class U>
constexpr T
value_or(U &&v)
const & {
2094 static_assert(
std::is_copy_constructible<T>::value &&
2095 std::is_convertible<U &&, T>::value,
2096 "T must be copy-constructible and convertible to from U&&");
2097 return bool(*
this) ? **
this :
static_cast<T>(
std::forward<U>(v));
2100 static_assert(
std::is_move_constructible<T>::value &&
2101 std::is_convertible<U &&, T>::value,
2102 "T must be move-constructible and convertible to from U&&");
2103 return bool(*
this) ?
std::move(**
this) :
static_cast<T>(
std::forward<U>(v));
2112#ifdef TL_EXPECTED_CXX14
2113template <
class Exp,
class F,
2114 detail::enable_if_t<!std::is_void<exp_t<Exp>>::value> * =
nullptr,
2115 class Ret =
decltype(
detail::invoke(
std::declval<F>(),
2116 *
std::declval<Exp>()))>
2117constexpr auto and_then_impl(Exp &&exp, F &&f) {
2118 static_assert(detail::is_expected<Ret>::value,
"F must return an expected");
2120 return exp.has_value()
2121 ?
detail::invoke(
std::forward<F>(f), *
std::forward<Exp>(exp))
2125template <
class Exp,
class F,
2126 detail::enable_if_t<std::is_void<exp_t<Exp>>::value> * =
nullptr,
2127 class Ret =
decltype(
detail::invoke(
std::declval<F>()))>
2128constexpr auto and_then_impl(Exp &&exp, F &&f) {
2129 static_assert(detail::is_expected<Ret>::value,
"F must return an expected");
2131 return exp.has_value() ?
detail::invoke(
std::forward<F>(f))
2135template <
class>
struct TC;
2136template <
class Exp,
class F,
2148template <
class Exp,
class F,
2159#ifdef TL_EXPECTED_CXX14
2160template <
class Exp,
class F,
2161 detail::enable_if_t<!std::is_void<exp_t<Exp>>::value> * =
nullptr,
2162 class Ret =
decltype(
detail::invoke(
std::declval<F>(),
2163 *
std::declval<Exp>())),
2164 detail::enable_if_t<!std::is_void<Ret>::value> * =
nullptr>
2165constexpr auto expected_map_impl(Exp &&exp, F &&f) {
2166 using result = ret_t<Exp, detail::decay_t<Ret>>;
2167 return exp.has_value() ? result(
detail::invoke(
std::forward<F>(f),
2168 *
std::forward<Exp>(exp)))
2169 : result(
unexpect,
std::forward<Exp>(exp).error());
2172template <
class Exp,
class F,
2173 detail::enable_if_t<!std::is_void<exp_t<Exp>>::value> * =
nullptr,
2174 class Ret =
decltype(
detail::invoke(
std::declval<F>(),
2175 *
std::declval<Exp>())),
2176 detail::enable_if_t<std::is_void<Ret>::value> * =
nullptr>
2177auto expected_map_impl(Exp &&exp, F &&f) {
2178 using result = expected<
void, err_t<Exp>>;
2179 if (exp.has_value()) {
2180 detail::invoke(
std::forward<F>(f), *
std::forward<Exp>(exp));
2184 return result(
unexpect,
std::forward<Exp>(exp).error());
2187template <
class Exp,
class F,
2188 detail::enable_if_t<std::is_void<exp_t<Exp>>::value> * =
nullptr,
2189 class Ret =
decltype(
detail::invoke(
std::declval<F>())),
2190 detail::enable_if_t<!std::is_void<Ret>::value> * =
nullptr>
2191constexpr auto expected_map_impl(Exp &&exp, F &&f) {
2192 using result = ret_t<Exp, detail::decay_t<Ret>>;
2193 return exp.has_value() ? result(
detail::invoke(
std::forward<F>(f)))
2194 : result(
unexpect,
std::forward<Exp>(exp).error());
2197template <
class Exp,
class F,
2198 detail::enable_if_t<std::is_void<exp_t<Exp>>::value> * =
nullptr,
2199 class Ret =
decltype(
detail::invoke(
std::declval<F>())),
2200 detail::enable_if_t<std::is_void<Ret>::value> * =
nullptr>
2201auto expected_map_impl(Exp &&exp, F &&f) {
2202 using result = expected<
void, err_t<Exp>>;
2203 if (exp.has_value()) {
2208 return result(
unexpect,
std::forward<Exp>(exp).error());
2211template <
class Exp,
class F,
2226template <
class Exp,
class F,
2241template <
class Exp,
class F,
2254template <
class Exp,
class F,
2269#if defined(TL_EXPECTED_CXX14
) && !defined(TL_EXPECTED_GCC49) &&
2270 !defined(TL_EXPECTED_GCC54) && !defined(TL_EXPECTED_GCC55)
2271template <
class Exp,
class F,
2272 detail::enable_if_t<!std::is_void<exp_t<Exp>>::value> * =
nullptr,
2273 class Ret =
decltype(
detail::invoke(
std::declval<F>(),
2274 std::declval<Exp>().error())),
2275 detail::enable_if_t<!std::is_void<Ret>::value> * =
nullptr>
2276constexpr auto map_error_impl(Exp &&exp, F &&f) {
2277 using result = expected<exp_t<Exp>, detail::decay_t<Ret>>;
2278 return exp.has_value()
2279 ? result(*
std::forward<Exp>(exp))
2281 std::forward<Exp>(exp).error()));
2283template <
class Exp,
class F,
2284 detail::enable_if_t<!std::is_void<exp_t<Exp>>::value> * =
nullptr,
2285 class Ret =
decltype(
detail::invoke(
std::declval<F>(),
2286 std::declval<Exp>().error())),
2287 detail::enable_if_t<std::is_void<Ret>::value> * =
nullptr>
2288auto map_error_impl(Exp &&exp, F &&f) {
2289 using result = expected<exp_t<Exp>, monostate>;
2290 if (exp.has_value()) {
2291 return result(*
std::forward<Exp>(exp));
2294 detail::invoke(
std::forward<F>(f),
std::forward<Exp>(exp).error());
2297template <
class Exp,
class F,
2298 detail::enable_if_t<std::is_void<exp_t<Exp>>::value> * =
nullptr,
2299 class Ret =
decltype(
detail::invoke(
std::declval<F>(),
2300 std::declval<Exp>().error())),
2301 detail::enable_if_t<!std::is_void<Ret>::value> * =
nullptr>
2302constexpr auto map_error_impl(Exp &&exp, F &&f) {
2303 using result = expected<exp_t<Exp>, detail::decay_t<Ret>>;
2304 return exp.has_value()
2307 std::forward<Exp>(exp).error()));
2309template <
class Exp,
class F,
2310 detail::enable_if_t<std::is_void<exp_t<Exp>>::value> * =
nullptr,
2311 class Ret =
decltype(
detail::invoke(
std::declval<F>(),
2312 std::declval<Exp>().error())),
2313 detail::enable_if_t<std::is_void<Ret>::value> * =
nullptr>
2314auto map_error_impl(Exp &&exp, F &&f) {
2315 using result = expected<exp_t<Exp>, monostate>;
2316 if (exp.has_value()) {
2320 detail::invoke(
std::forward<F>(f),
std::forward<Exp>(exp).error());
2324template <
class Exp,
class F,
2339template <
class Exp,
class F,
2354template <
class Exp,
class F,
2369template <
class Exp,
class F,
2385#ifdef TL_EXPECTED_CXX14
2386template <
class Exp,
class F,
2387 class Ret =
decltype(
detail::invoke(
std::declval<F>(),
2388 std::declval<Exp>().error())),
2389 detail::enable_if_t<!std::is_void<Ret>::value> * =
nullptr>
2390constexpr auto or_else_impl(Exp &&exp, F &&f) {
2391 static_assert(detail::is_expected<Ret>::value,
"F must return an expected");
2392 return exp.has_value() ?
std::forward<Exp>(exp)
2394 std::forward<Exp>(exp).error());
2397template <
class Exp,
class F,
2398 class Ret =
decltype(
detail::invoke(
std::declval<F>(),
2399 std::declval<Exp>().error())),
2400 detail::enable_if_t<std::is_void<Ret>::value> * =
nullptr>
2401detail::decay_t<Exp> or_else_impl(Exp &&exp, F &&f) {
2402 return exp.has_value() ?
std::forward<Exp>(exp)
2404 std::forward<Exp>(exp).error()),
2405 std::forward<Exp>(exp));
2408template <
class Exp,
class F,
2419template <
class Exp,
class F,
2432template <
class T,
class E,
class U,
class F>
2435 return (lhs.has_value() != rhs.has_value())
2437 : (!lhs.has_value() ? lhs.error() == rhs.error() : *lhs == *rhs);
2439template <
class T,
class E,
class U,
class F>
2442 return (lhs.has_value() != rhs.has_value())
2444 : (!lhs.has_value() ? lhs.error() != rhs.error() : *lhs != *rhs);
2446template <
class E,
class F>
2449 return (lhs.has_value() != rhs.has_value())
2451 : (!lhs.has_value() ? lhs.error() == rhs.error() :
true);
2453template <
class E,
class F>
2456 return (lhs.has_value() != rhs.has_value())
2458 : (!lhs.has_value() ? lhs.error() != rhs.error() :
false);
2461template <
class T,
class E,
class U>
2463 return x.has_value() ? *x == v :
false;
2465template <
class T,
class E,
class U>
2467 return x.has_value() ? *x == v :
false;
2469template <
class T,
class E,
class U>
2471 return x.has_value() ? *x != v :
true;
2473template <
class T,
class E,
class U>
2475 return x.has_value() ? *x != v :
true;
2478template <
class T,
class E>
2480 return x.has_value() ?
false : x.error() == e.error();
2482template <
class T,
class E>
2484 return x.has_value() ?
false : x.error() == e.error();
2486template <
class T,
class E>
2488 return x.has_value() ?
true : x.error() != e.error();
2490template <
class T,
class E>
2492 return x.has_value() ?
true : x.error() != e.error();
2495template <
class T,
class E,
2496 detail::enable_if_t<(std::is_void<T>::value ||
2497 std::is_move_constructible<T>::value) &&
2498 detail::is_swappable<T>::value &&
2499 std::is_move_constructible<E>::value &&
2500 detail::is_swappable<E>::value> * =
nullptr>
const E && error() const &&
virtual const char * what() const noexcept override
const E & error() const &
TL_EXPECTED_11_CONSTEXPR E && error() &&
expected TL_EXPECTED_11_CONSTEXPR or_else(F &&f) &
constexpr T value_or(U &&v) const &
TL_EXPECTED_11_CONSTEXPR const U & value() const &
constexpr const E && error() const &&
expected constexpr or_else(F &&f) const &&
constexpr expected(unexpect_t, Args &&...args)
TL_EXPECTED_11_CONSTEXPR expected(expected< U, G > &&rhs)
constexpr expected(in_place_t, std::initializer_list< U > il, Args &&...args)
constexpr const U & operator*() const &
expected & operator=(const unexpected< G > &rhs)
constexpr expected(const expected &rhs)=default
unexpected< E > unexpected_type
TL_EXPECTED_11_CONSTEXPR T * operator->()
expected & operator=(expected &&rhs)=default
TL_EXPECTED_11_CONSTEXPR E & error() &
TL_EXPECTED_11_CONSTEXPR U & value() &
TL_EXPECTED_MSVC2015_CONSTEXPR expected(U &&v)
detail::enable_if_t< detail::is_swappable< OT >::value &&detail::is_swappable< OE >::value &&(std::is_nothrow_move_constructible< OT >::value||std::is_nothrow_move_constructible< OE >::value)> swap(expected &rhs) noexcept(std::is_nothrow_move_constructible< T >::value &&detail::is_nothrow_swappable< T >::value &&std::is_nothrow_move_constructible< E >::value &&detail::is_nothrow_swappable< E >::value)
void emplace(std::initializer_list< U > il, Args &&...args)
constexpr expected(unexpect_t, std::initializer_list< U > il, Args &&...args)
expected constexpr or_else(F &&f) const &
constexpr bool has_value() const noexcept
TL_EXPECTED_11_CONSTEXPR U && operator*() &&
constexpr expected()=default
TL_EXPECTED_11_CONSTEXPR expected(const expected< U, G > &rhs)
constexpr expected(in_place_t, Args &&...args)
void emplace(Args &&...args)
constexpr const E & error() const &
constexpr expected(unexpected< G > &&e) noexcept(std::is_nothrow_constructible< E, G && >::value)
constexpr const T * operator->() const
TL_EXPECTED_11_CONSTEXPR T value_or(U &&v) &&
expected & operator=(unexpected< G > &&rhs) noexcept
constexpr expected(const unexpected< G > &e)
constexpr const U && operator*() const &&
TL_EXPECTED_11_CONSTEXPR U & operator*() &
TL_EXPECTED_11_CONSTEXPR const U && value() const &&
expected & operator=(U &&v)
expected & operator=(const expected &rhs)=default
constexpr operator bool() const noexcept
constexpr expected(expected &&rhs)=default
TL_EXPECTED_11_CONSTEXPR U && value() &&
expected TL_EXPECTED_11_CONSTEXPR or_else(F &&f) &&
constexpr unexpected(in_place_t, Args &&...args)
constexpr unexpected(const E &e)
constexpr const E & error() const &
TL_EXPECTED_11_CONSTEXPR E && error() &&
TL_EXPECTED_11_CONSTEXPR E & error() &
constexpr unexpected(in_place_t, std::initializer_list< U > l, Args &&...args)
constexpr const E && error() const &&
constexpr unexpected(E &&e)
std::is_same< decltype(swap(std::declval< T & >(), std::declval< U & >())), tag > uses_std(int)
std::false_type can_swap(...) noexcept(false)
tag swap(T(&a)[N], T(&b)[N])
std::true_type can_swap(int) noexcept(noexcept(swap(std::declval< T & >(), std::declval< U & >())))
std::false_type uses_std(...)
constexpr auto invoke(Fn &&f, Args &&...args) noexcept(noexcept(std::forward< Fn >(f)(std::forward< Args >(args)...))) -> decltype(std::forward< Fn >(f)(std::forward< Args >(args)...))
typename std::conditional< B, T, F >::type conditional_t
invoke_result_impl< F, void, Us... > invoke_result
typename std::remove_reference< T >::type remove_reference_t
typename std::enable_if< E, T >::type enable_if_t
static constexpr no_init_t no_init
TL_EXPECTED_11_CONSTEXPR void throw_exception(E &&e)
typename std::decay< T >::type decay_t
typename std::remove_const< T >::type remove_const_t
constexpr auto invoke(Fn &&f, Args &&...args) noexcept(noexcept(std::mem_fn(f)(std::forward< Args >(args)...))) -> decltype(std::mem_fn(f)(std::forward< Args >(args)...))
constexpr bool operator!=(const unexpected< E > &e, const expected< T, E > &x)
constexpr bool operator!=(const unexpected< E > &lhs, const unexpected< E > &rhs)
constexpr bool operator<(const unexpected< E > &lhs, const unexpected< E > &rhs)
constexpr bool operator>(const unexpected< E > &lhs, const unexpected< E > &rhs)
constexpr bool operator==(const unexpected< E > &lhs, const unexpected< E > &rhs)
constexpr bool operator==(const expected< void, E > &lhs, const expected< void, F > &rhs)
constexpr bool operator!=(const expected< T, E > &lhs, const expected< U, F > &rhs)
unexpected< typename std::decay< E >::type > make_unexpected(E &&e)
constexpr bool operator<=(const unexpected< E > &lhs, const unexpected< E > &rhs)
void swap(expected< T, E > &lhs, expected< T, E > &rhs) noexcept(noexcept(lhs.swap(rhs)))
constexpr bool operator!=(const expected< T, E > &x, const U &v)
constexpr bool operator==(const unexpected< E > &e, const expected< T, E > &x)
constexpr bool operator==(const expected< T, E > &x, const U &v)
constexpr bool operator==(const U &v, const expected< T, E > &x)
static constexpr unexpect_t unexpect
constexpr bool operator!=(const expected< T, E > &x, const unexpected< E > &e)
static constexpr in_place_t in_place
constexpr bool operator>=(const unexpected< E > &lhs, const unexpected< E > &rhs)
constexpr bool operator!=(const expected< void, E > &lhs, const expected< void, F > &rhs)
constexpr bool operator==(const expected< T, E > &x, const unexpected< E > &e)
constexpr bool operator==(const expected< T, E > &lhs, const expected< U, F > &rhs)
constexpr bool operator!=(const U &v, const expected< T, E > &x)
#define TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(T)
#define TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T)
#define TL_EXPECTED_MSVC2015_CONSTEXPR
#define TL_EXPECTED_IS_TRIVIALLY_COPY_ASSIGNABLE(T)
#define TL_EXPECTED_11_CONSTEXPR
constexpr default_constructor_tag()=default
expected_copy_assign_base(expected_copy_assign_base &&rhs)=default
expected_copy_assign_base(const expected_copy_assign_base &rhs)=default
expected_copy_assign_base()=default
expected_copy_assign_base & operator=(const expected_copy_assign_base &rhs)
expected_copy_assign_base & operator=(expected_copy_assign_base &&rhs)=default
expected_copy_base()=default
expected_copy_base & operator=(const expected_copy_base &rhs)=default
expected_copy_base(const expected_copy_base &rhs)
expected_copy_base(expected_copy_base &&rhs)=default
expected_copy_base & operator=(expected_copy_base &&rhs)=default
constexpr expected_default_ctor_base(expected_default_ctor_base const &) noexcept=default
constexpr expected_default_ctor_base(expected_default_ctor_base &&) noexcept=default
constexpr expected_default_ctor_base(default_constructor_tag)
expected_default_ctor_base & operator=(expected_default_ctor_base const &) noexcept=default
expected_default_ctor_base & operator=(expected_default_ctor_base &&) noexcept=default
constexpr expected_default_ctor_base() noexcept=delete
expected_default_ctor_base & operator=(expected_default_ctor_base &&) noexcept=default
constexpr expected_default_ctor_base(expected_default_ctor_base const &) noexcept=default
expected_default_ctor_base & operator=(expected_default_ctor_base const &) noexcept=default
constexpr expected_default_ctor_base(expected_default_ctor_base &&) noexcept=default
constexpr expected_default_ctor_base(default_constructor_tag)
constexpr expected_default_ctor_base() noexcept=default
expected_delete_assign_base(expected_delete_assign_base &&) noexcept=default
expected_delete_assign_base(const expected_delete_assign_base &)=default
expected_delete_assign_base & operator=(expected_delete_assign_base &&) noexcept=delete
expected_delete_assign_base()=default
expected_delete_assign_base & operator=(const expected_delete_assign_base &)=delete
expected_delete_assign_base(expected_delete_assign_base &&) noexcept=default
expected_delete_assign_base & operator=(expected_delete_assign_base &&) noexcept=default
expected_delete_assign_base & operator=(const expected_delete_assign_base &)=delete
expected_delete_assign_base(const expected_delete_assign_base &)=default
expected_delete_assign_base()=default
expected_delete_assign_base(expected_delete_assign_base &&) noexcept=default
expected_delete_assign_base & operator=(const expected_delete_assign_base &)=default
expected_delete_assign_base(const expected_delete_assign_base &)=default
expected_delete_assign_base()=default
expected_delete_assign_base & operator=(expected_delete_assign_base &&) noexcept=delete
expected_delete_assign_base(expected_delete_assign_base &&) noexcept=default
expected_delete_assign_base & operator=(const expected_delete_assign_base &)=default
expected_delete_assign_base()=default
expected_delete_assign_base & operator=(expected_delete_assign_base &&) noexcept=default
expected_delete_assign_base(const expected_delete_assign_base &)=default
expected_delete_ctor_base & operator=(expected_delete_ctor_base &&) noexcept=default
expected_delete_ctor_base & operator=(const expected_delete_ctor_base &)=default
expected_delete_ctor_base(expected_delete_ctor_base &&) noexcept=delete
expected_delete_ctor_base()=default
expected_delete_ctor_base(const expected_delete_ctor_base &)=delete
expected_delete_ctor_base(const expected_delete_ctor_base &)=delete
expected_delete_ctor_base()=default
expected_delete_ctor_base(expected_delete_ctor_base &&) noexcept=default
expected_delete_ctor_base & operator=(const expected_delete_ctor_base &)=default
expected_delete_ctor_base & operator=(expected_delete_ctor_base &&) noexcept=default
expected_delete_ctor_base(const expected_delete_ctor_base &)=default
expected_delete_ctor_base & operator=(expected_delete_ctor_base &&) noexcept=default
expected_delete_ctor_base(expected_delete_ctor_base &&) noexcept=delete
expected_delete_ctor_base()=default
expected_delete_ctor_base & operator=(const expected_delete_ctor_base &)=default
expected_delete_ctor_base & operator=(expected_delete_ctor_base &&) noexcept=default
expected_delete_ctor_base & operator=(const expected_delete_ctor_base &)=default
expected_delete_ctor_base()=default
expected_delete_ctor_base(const expected_delete_ctor_base &)=default
expected_delete_ctor_base(expected_delete_ctor_base &&) noexcept=default
expected_move_assign_base()=default
expected_move_assign_base & operator=(const expected_move_assign_base &rhs)=default
expected_move_assign_base & operator=(expected_move_assign_base &&rhs) noexcept(std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value)
expected_move_assign_base(const expected_move_assign_base &rhs)=default
expected_move_assign_base(expected_move_assign_base &&rhs)=default
expected_move_base(expected_move_base &&rhs) noexcept(std::is_nothrow_move_constructible< T >::value)
expected_move_base(const expected_move_base &rhs)=default
expected_move_base & operator=(const expected_move_base &rhs)=default
expected_move_base & operator=(expected_move_base &&rhs)=default
expected_move_base()=default
constexpr const unexpected< E > && geterr() const &&
void assign(Rhs &&rhs) noexcept
void construct_with(Rhs &&) noexcept
TL_EXPECTED_11_CONSTEXPR unexpected< E > & geterr() &
void construct_error(Args &&...args) noexcept
TL_EXPECTED_11_CONSTEXPR void destroy_val()
TL_EXPECTED_11_CONSTEXPR unexpected< E > && geterr() &&
void construct() noexcept
constexpr const unexpected< E > & geterr() const &
constexpr const unexpected< E > && geterr() const &&
TL_EXPECTED_11_CONSTEXPR T & get() &
void construct(Args &&...args) noexcept
TL_EXPECTED_11_CONSTEXPR void destroy_val()
constexpr const unexpected< E > & geterr() const &
TL_EXPECTED_11_CONSTEXPR T && get() &&
void construct_with(Rhs &&rhs) noexcept
constexpr const T && get() const &&
constexpr const T & get() const &
void construct_error(Args &&...args) noexcept
void assign_common(Rhs &&rhs)
TL_EXPECTED_11_CONSTEXPR unexpected< E > && geterr() &&
TL_EXPECTED_11_CONSTEXPR unexpected< E > & geterr() &
expected_storage_base(expected_storage_base &&)=default
constexpr expected_storage_base(unexpect_t, std::initializer_list< U > il, Args &&...args)
constexpr expected_storage_base(no_init_t)
constexpr expected_storage_base(in_place_t, Args &&...args)
constexpr expected_storage_base(in_place_t, std::initializer_list< U > il, Args &&...args)
expected_storage_base & operator=(const expected_storage_base &)=default
constexpr expected_storage_base()
expected_storage_base & operator=(expected_storage_base &&)=default
expected_storage_base(const expected_storage_base &)=default
unexpected< E > m_unexpect
constexpr expected_storage_base(unexpect_t, Args &&...args)
expected_storage_base & operator=(const expected_storage_base &)=default
expected_storage_base(const expected_storage_base &)=default
constexpr expected_storage_base(unexpect_t, Args &&...args)
unexpected< E > m_unexpect
constexpr expected_storage_base()
expected_storage_base(expected_storage_base &&)=default
constexpr expected_storage_base(unexpect_t, std::initializer_list< U > il, Args &&...args)
constexpr expected_storage_base(in_place_t, std::initializer_list< U > il, Args &&...args)
constexpr expected_storage_base(in_place_t, Args &&...args)
expected_storage_base & operator=(expected_storage_base &&)=default
TL_EXPECTED_MSVC2015_CONSTEXPR expected_storage_base(no_init_t)
expected_storage_base(expected_storage_base &&)=default
~expected_storage_base()=default
constexpr expected_storage_base(no_init_t)
expected_storage_base & operator=(const expected_storage_base &)=default
constexpr expected_storage_base(in_place_t, std::initializer_list< U > il, Args &&...args)
constexpr expected_storage_base(unexpect_t, Args &&...args)
constexpr expected_storage_base()
expected_storage_base(const expected_storage_base &)=default
unexpected< E > m_unexpect
expected_storage_base & operator=(expected_storage_base &&)=default
constexpr expected_storage_base(unexpect_t, std::initializer_list< U > il, Args &&...args)
constexpr expected_storage_base(in_place_t, Args &&...args)
constexpr expected_storage_base(unexpect_t, std::initializer_list< U > il, Args &&...args)
expected_storage_base & operator=(expected_storage_base &&)=default
unexpected< E > m_unexpect
expected_storage_base(expected_storage_base &&)=default
constexpr expected_storage_base(no_init_t)
expected_storage_base & operator=(const expected_storage_base &)=default
constexpr expected_storage_base(in_place_t)
constexpr expected_storage_base()
constexpr expected_storage_base(unexpect_t, Args &&...args)
expected_storage_base(const expected_storage_base &)=default
~expected_storage_base()=default
expected_storage_base(expected_storage_base &&)=default
expected_storage_base & operator=(expected_storage_base &&)=default
expected_storage_base(const expected_storage_base &)=default
unexpected< E > m_unexpect
constexpr expected_storage_base(no_init_t)
constexpr expected_storage_base(in_place_t)
constexpr expected_storage_base(unexpect_t, std::initializer_list< U > il, Args &&...args)
expected_storage_base & operator=(const expected_storage_base &)=default
constexpr expected_storage_base(unexpect_t, Args &&...args)
constexpr expected_storage_base()
constexpr expected_storage_base(unexpect_t, std::initializer_list< U > il, Args &&...args)
constexpr expected_storage_base(in_place_t, std::initializer_list< U > il, Args &&...args)
unexpected< E > m_unexpect
constexpr expected_storage_base(no_init_t)
constexpr expected_storage_base(in_place_t, Args &&...args)
constexpr expected_storage_base(unexpect_t, Args &&...args)
decltype(detail::invoke(std::declval< F >(), std::declval< Us >()...)) type