Skip to content

Commit

Permalink
🩹 Fix default expected constructors
Browse files Browse the repository at this point in the history
When `= default`ing constructors, it can be detrimental to specify
the `noexcept`-ness and `constexpr`-ness of the constructor since it
may either be misleading, or worse, implicitly deleted if the
`noexcept`ness cannot be satisfied.

GCC has determined that `expected() noexcept = default` is resulting in
an implicitly deleted default-constructor due to the constructor not
actually being `noexcept`. The exact reason for this failure is not
known, but realistically, the non-throwing nature of the constructor
should *not* be cause for this type of issue.

As a result, all `expected` constructors have removed `constexpr` or
implicitly expected `noexcept`-ness to instead simply be determined
by the compiler with `= default`.
  • Loading branch information
bitwizeshift committed Jan 5, 2021
1 parent 8000e03 commit 075f5e4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/alloy-core/include/alloy/core/utilities/expected.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ namespace alloy::core {

/// \brief Constructs the underlying value by default-construction by
/// calling T's constructor
constexpr expected() = default;
expected() = default;

/// \brief Constructs the underlying value of this expected by calling
/// T's constructor with the given args
Expand Down Expand Up @@ -334,12 +334,12 @@ namespace alloy::core {
/// \brief Constructs this expected by moving the contents of \p other
///
/// \param other the other expected to move
constexpr expected(expected&& other) = default;
expected(expected&& other) = default;

/// \brief Constructs this expected by copying the contents of \p other
///
/// \param other the other expected to copy
constexpr expected(const expected& other) = default;
expected(const expected& other) = default;

//--------------------------------------------------------------------------

Expand Down Expand Up @@ -516,7 +516,7 @@ namespace alloy::core {
public:

/// \brief Constructs this expected successfully
constexpr expected() noexcept = default;
expected() = default;

/// \brief Constructs the underlying error of this expected
///
Expand All @@ -528,12 +528,12 @@ namespace alloy::core {
/// \brief Constructs this expected by moving the contents of \p other
///
/// \param other the other expected to move
constexpr expected(expected&& other) = default;
expected(expected&& other) = default;

/// \brief Constructs this expected by copying the contents of \p other
///
/// \param other the other expected to copy
constexpr expected(const expected& other) = default;
expected(const expected& other) = default;

//--------------------------------------------------------------------------

Expand Down

0 comments on commit 075f5e4

Please sign in to comment.