mirror of
https://github.com/TartanLlama/expected.git
synced 2025-07-30 00:47:18 +02:00
Fix #145
This commit is contained in:
@ -528,6 +528,10 @@ template <class T, class E> struct expected_storage_base<T, E, true, true> {
|
|||||||
Args &&...args)
|
Args &&...args)
|
||||||
: m_unexpect(il, std::forward<Args>(args)...), m_has_val(false) {}
|
: m_unexpect(il, std::forward<Args>(args)...), m_has_val(false) {}
|
||||||
|
|
||||||
|
expected_storage_base(const expected_storage_base &) = default;
|
||||||
|
expected_storage_base(expected_storage_base &&) = default;
|
||||||
|
expected_storage_base &operator=(const expected_storage_base &) = default;
|
||||||
|
expected_storage_base &operator=(expected_storage_base &&) = default;
|
||||||
~expected_storage_base() = default;
|
~expected_storage_base() = default;
|
||||||
union {
|
union {
|
||||||
T m_val;
|
T m_val;
|
||||||
@ -569,6 +573,10 @@ template <class T, class E> struct expected_storage_base<T, E, true, false> {
|
|||||||
Args &&...args)
|
Args &&...args)
|
||||||
: m_unexpect(il, std::forward<Args>(args)...), m_has_val(false) {}
|
: m_unexpect(il, std::forward<Args>(args)...), m_has_val(false) {}
|
||||||
|
|
||||||
|
expected_storage_base(const expected_storage_base &) = default;
|
||||||
|
expected_storage_base(expected_storage_base &&) = default;
|
||||||
|
expected_storage_base &operator=(const expected_storage_base &) = default;
|
||||||
|
expected_storage_base &operator=(expected_storage_base &&) = default;
|
||||||
~expected_storage_base() {
|
~expected_storage_base() {
|
||||||
if (!m_has_val) {
|
if (!m_has_val) {
|
||||||
m_unexpect.~unexpected<E>();
|
m_unexpect.~unexpected<E>();
|
||||||
@ -614,6 +622,10 @@ template <class T, class E> struct expected_storage_base<T, E, false, true> {
|
|||||||
Args &&...args)
|
Args &&...args)
|
||||||
: m_unexpect(il, std::forward<Args>(args)...), m_has_val(false) {}
|
: m_unexpect(il, std::forward<Args>(args)...), m_has_val(false) {}
|
||||||
|
|
||||||
|
expected_storage_base(const expected_storage_base &) = default;
|
||||||
|
expected_storage_base(expected_storage_base &&) = default;
|
||||||
|
expected_storage_base &operator=(const expected_storage_base &) = default;
|
||||||
|
expected_storage_base &operator=(expected_storage_base &&) = default;
|
||||||
~expected_storage_base() {
|
~expected_storage_base() {
|
||||||
if (m_has_val) {
|
if (m_has_val) {
|
||||||
m_val.~T();
|
m_val.~T();
|
||||||
@ -654,6 +666,10 @@ template <class E> struct expected_storage_base<void, E, false, true> {
|
|||||||
Args &&...args)
|
Args &&...args)
|
||||||
: m_unexpect(il, std::forward<Args>(args)...), m_has_val(false) {}
|
: m_unexpect(il, std::forward<Args>(args)...), m_has_val(false) {}
|
||||||
|
|
||||||
|
expected_storage_base(const expected_storage_base &) = default;
|
||||||
|
expected_storage_base(expected_storage_base &&) = default;
|
||||||
|
expected_storage_base &operator=(const expected_storage_base &) = default;
|
||||||
|
expected_storage_base &operator=(expected_storage_base &&) = default;
|
||||||
~expected_storage_base() = default;
|
~expected_storage_base() = default;
|
||||||
struct dummy {};
|
struct dummy {};
|
||||||
union {
|
union {
|
||||||
@ -684,6 +700,10 @@ template <class E> struct expected_storage_base<void, E, false, false> {
|
|||||||
Args &&...args)
|
Args &&...args)
|
||||||
: m_unexpect(il, std::forward<Args>(args)...), m_has_val(false) {}
|
: m_unexpect(il, std::forward<Args>(args)...), m_has_val(false) {}
|
||||||
|
|
||||||
|
expected_storage_base(const expected_storage_base &) = default;
|
||||||
|
expected_storage_base(expected_storage_base &&) = default;
|
||||||
|
expected_storage_base &operator=(const expected_storage_base &) = default;
|
||||||
|
expected_storage_base &operator=(expected_storage_base &&) = default;
|
||||||
~expected_storage_base() {
|
~expected_storage_base() {
|
||||||
if (!m_has_val) {
|
if (!m_has_val) {
|
||||||
m_unexpect.~unexpected<E>();
|
m_unexpect.~unexpected<E>();
|
||||||
@ -942,14 +962,16 @@ struct expected_operations_base<void, E> : expected_storage_base<void, E> {
|
|||||||
// This specialization is for when T and E are trivially copy constructible
|
// This specialization is for when T and E are trivially copy constructible
|
||||||
template <class T, class E,
|
template <class T, class E,
|
||||||
bool = is_void_or<T, TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T)>::
|
bool = is_void_or<T, TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T)>::
|
||||||
value &&TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(E)::value>
|
value &&TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(E)::value,
|
||||||
|
bool = (is_copy_constructible_or_void<T>::value &&
|
||||||
|
std::is_copy_constructible<E>::value)>
|
||||||
struct expected_copy_base : expected_operations_base<T, E> {
|
struct expected_copy_base : expected_operations_base<T, E> {
|
||||||
using expected_operations_base<T, E>::expected_operations_base;
|
using expected_operations_base<T, E>::expected_operations_base;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This specialization is for when T or E are not trivially copy constructible
|
// This specialization is for when T or E are non-trivially copy constructible
|
||||||
template <class T, class E>
|
template <class T, class E>
|
||||||
struct expected_copy_base<T, E, false> : expected_operations_base<T, E> {
|
struct expected_copy_base<T, E, false, true> : expected_operations_base<T, E> {
|
||||||
using expected_operations_base<T, E>::expected_operations_base;
|
using expected_operations_base<T, E>::expected_operations_base;
|
||||||
|
|
||||||
expected_copy_base() = default;
|
expected_copy_base() = default;
|
||||||
@ -1010,13 +1032,17 @@ template <class T, class E,
|
|||||||
TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(T)>>::value
|
TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(T)>>::value
|
||||||
&&TL_EXPECTED_IS_TRIVIALLY_COPY_ASSIGNABLE(E)::value
|
&&TL_EXPECTED_IS_TRIVIALLY_COPY_ASSIGNABLE(E)::value
|
||||||
&&TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(E)::value
|
&&TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(E)::value
|
||||||
&&TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(E)::value>
|
&&TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(E)::value,
|
||||||
|
bool = (is_copy_constructible_or_void<T>::value &&
|
||||||
|
std::is_copy_constructible<E>::value &&
|
||||||
|
is_copy_assignable_or_void<T>::value &&
|
||||||
|
std::is_copy_assignable<E>::value)>
|
||||||
struct expected_copy_assign_base : expected_move_base<T, E> {
|
struct expected_copy_assign_base : expected_move_base<T, E> {
|
||||||
using expected_move_base<T, E>::expected_move_base;
|
using expected_move_base<T, E>::expected_move_base;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, class E>
|
template <class T, class E>
|
||||||
struct expected_copy_assign_base<T, E, false> : expected_move_base<T, E> {
|
struct expected_copy_assign_base<T, E, false, true> : expected_move_base<T, E> {
|
||||||
using expected_move_base<T, E>::expected_move_base;
|
using expected_move_base<T, E>::expected_move_base;
|
||||||
|
|
||||||
expected_copy_assign_base() = default;
|
expected_copy_assign_base() = default;
|
||||||
|
Reference in New Issue
Block a user