Skip to content

Commit c5ce092

Browse files
committed
prevents MSVC from trying to construct private or non default constructible result types
1 parent 0cfe9b4 commit c5ce092

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎src/iceberg/expected.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,8 @@ struct storage_base {
362362
storage_base& operator=(storage_base const&) = default;
363363
storage_base& operator=(storage_base&&) = default;
364364

365-
constexpr storage_base() noexcept(std::is_nothrow_default_constructible_v<T>)
365+
template <class U = T, std::enable_if_t<std::is_default_constructible_v<U>, int> = 0>
366+
constexpr storage_base() noexcept(std::is_nothrow_default_constructible_v<U>)
366367
: m_val(), m_has_val(true) {}
367368
constexpr storage_base(no_init_t) noexcept : m_no_init(), m_has_val(false) {}
368369

@@ -429,7 +430,8 @@ struct storage_base<T, E, false> {
429430
storage_base& operator=(storage_base const&) = default;
430431
storage_base& operator=(storage_base&&) = default;
431432

432-
constexpr storage_base() noexcept(std::is_nothrow_default_constructible_v<T>)
433+
template <class U = T, std::enable_if_t<std::is_default_constructible_v<U>, int> = 0>
434+
constexpr storage_base() noexcept(std::is_nothrow_default_constructible_v<U>)
433435
: m_val(), m_has_val(true) {}
434436
constexpr storage_base(no_init_t) noexcept : m_no_init(), m_has_val(false) {}
435437

0 commit comments

Comments
 (0)