Skip to content

Commit 41c3d29

Browse files
committed
fix Result ctor order warnings
1 parent dc99edf commit 41c3d29

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

include/common/result.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,17 @@ class Result {
7979
requires Sentinel<T> && (std::constructible_from<U, Errs> || ...)
8080
&& (!std::convertible_to<U, T>)
8181
constexpr Result(U&& error)
82-
: value(sentinel_v<T>),
83-
error(std::forward<U>(error)) {}
82+
: error(std::forward<U>(error)),
83+
value(sentinel_v<T>) {}
8484

8585
// Construct a Result with an error, initializing the normal value to its sentinel value.
8686
// Constraint: type T has a sentinel value
8787
// Constraint: some type in Errs can be constructed from type U
8888
template<typename U>
8989
requires Sentinel<U> && (std::constructible_from<U, Errs> || ...)
9090
explicit constexpr Result<U>(U&& error)
91-
: value(sentinel_v<T>),
92-
error(std::forward<U>(error)) {}
91+
: error(std::forward<U>(error)),
92+
value(sentinel_v<T>) {}
9393

9494
// Get the given error type, if it exists
9595
// Constraint: some type Errs can be constructed from type U

tests/Result.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,5 @@ void initialize() {
1717
static_assert(a.get() == a.get<int>());
1818
constexpr zest::Result<int, MyError2> b(2);
1919
static_assert(a == b);
20-
21-
zest::Result<int, IntError> c(2);
22-
zest::Result<int, IntError> d(IntError(2));
20+
auto c = a.get<MyError>();
2321
}

0 commit comments

Comments
 (0)