Skip to content

Commit f7f82e3

Browse files
committed
Fix #145
1 parent db7add9 commit f7f82e3

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

include/tl/expected.hpp

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,10 @@ template <class T, class E> struct expected_storage_base<T, E, true, true> {
528528
Args &&...args)
529529
: m_unexpect(il, std::forward<Args>(args)...), m_has_val(false) {}
530530

531+
expected_storage_base(const expected_storage_base &) = default;
532+
expected_storage_base(expected_storage_base &&) = default;
533+
expected_storage_base &operator=(const expected_storage_base &) = default;
534+
expected_storage_base &operator=(expected_storage_base &&) = default;
531535
~expected_storage_base() = default;
532536
union {
533537
T m_val;
@@ -569,6 +573,10 @@ template <class T, class E> struct expected_storage_base<T, E, true, false> {
569573
Args &&...args)
570574
: m_unexpect(il, std::forward<Args>(args)...), m_has_val(false) {}
571575

576+
expected_storage_base(const expected_storage_base &) = default;
577+
expected_storage_base(expected_storage_base &&) = default;
578+
expected_storage_base &operator=(const expected_storage_base &) = default;
579+
expected_storage_base &operator=(expected_storage_base &&) = default;
572580
~expected_storage_base() {
573581
if (!m_has_val) {
574582
m_unexpect.~unexpected<E>();
@@ -614,6 +622,10 @@ template <class T, class E> struct expected_storage_base<T, E, false, true> {
614622
Args &&...args)
615623
: m_unexpect(il, std::forward<Args>(args)...), m_has_val(false) {}
616624

625+
expected_storage_base(const expected_storage_base &) = default;
626+
expected_storage_base(expected_storage_base &&) = default;
627+
expected_storage_base &operator=(const expected_storage_base &) = default;
628+
expected_storage_base &operator=(expected_storage_base &&) = default;
617629
~expected_storage_base() {
618630
if (m_has_val) {
619631
m_val.~T();
@@ -654,6 +666,10 @@ template <class E> struct expected_storage_base<void, E, false, true> {
654666
Args &&...args)
655667
: m_unexpect(il, std::forward<Args>(args)...), m_has_val(false) {}
656668

669+
expected_storage_base(const expected_storage_base &) = default;
670+
expected_storage_base(expected_storage_base &&) = default;
671+
expected_storage_base &operator=(const expected_storage_base &) = default;
672+
expected_storage_base &operator=(expected_storage_base &&) = default;
657673
~expected_storage_base() = default;
658674
struct dummy {};
659675
union {
@@ -684,6 +700,10 @@ template <class E> struct expected_storage_base<void, E, false, false> {
684700
Args &&...args)
685701
: m_unexpect(il, std::forward<Args>(args)...), m_has_val(false) {}
686702

703+
expected_storage_base(const expected_storage_base &) = default;
704+
expected_storage_base(expected_storage_base &&) = default;
705+
expected_storage_base &operator=(const expected_storage_base &) = default;
706+
expected_storage_base &operator=(expected_storage_base &&) = default;
687707
~expected_storage_base() {
688708
if (!m_has_val) {
689709
m_unexpect.~unexpected<E>();
@@ -942,14 +962,16 @@ struct expected_operations_base<void, E> : expected_storage_base<void, E> {
942962
// This specialization is for when T and E are trivially copy constructible
943963
template <class T, class E,
944964
bool = is_void_or<T, TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T)>::
945-
value &&TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(E)::value>
965+
value &&TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(E)::value,
966+
bool = (is_copy_constructible_or_void<T>::value &&
967+
std::is_copy_constructible<E>::value)>
946968
struct expected_copy_base : expected_operations_base<T, E> {
947969
using expected_operations_base<T, E>::expected_operations_base;
948970
};
949971

950-
// This specialization is for when T or E are not trivially copy constructible
972+
// This specialization is for when T or E are non-trivially copy constructible
951973
template <class T, class E>
952-
struct expected_copy_base<T, E, false> : expected_operations_base<T, E> {
974+
struct expected_copy_base<T, E, false, true> : expected_operations_base<T, E> {
953975
using expected_operations_base<T, E>::expected_operations_base;
954976

955977
expected_copy_base() = default;
@@ -1010,13 +1032,17 @@ template <class T, class E,
10101032
TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(T)>>::value
10111033
&&TL_EXPECTED_IS_TRIVIALLY_COPY_ASSIGNABLE(E)::value
10121034
&&TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(E)::value
1013-
&&TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(E)::value>
1035+
&&TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(E)::value,
1036+
bool = (is_copy_constructible_or_void<T>::value &&
1037+
std::is_copy_constructible<E>::value &&
1038+
is_copy_assignable_or_void<T>::value &&
1039+
std::is_copy_assignable<E>::value)>
10141040
struct expected_copy_assign_base : expected_move_base<T, E> {
10151041
using expected_move_base<T, E>::expected_move_base;
10161042
};
10171043

10181044
template <class T, class E>
1019-
struct expected_copy_assign_base<T, E, false> : expected_move_base<T, E> {
1045+
struct expected_copy_assign_base<T, E, false, true> : expected_move_base<T, E> {
10201046
using expected_move_base<T, E>::expected_move_base;
10211047

10221048
expected_copy_assign_base() = default;

0 commit comments

Comments
 (0)