Skip to content
This repository was archived by the owner on May 3, 2026. It is now read-only.

Commit 212e299

Browse files
committed
use concepts instead of traits wherever possible in result.hpp
1 parent 156078f commit 212e299

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

include/common/result.hpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,7 @@ class Result {
561561
// compiler will compile a branch where f is invoked with an unsupported argument
562562
// type
563563
if constexpr (!Invocable<Self, F, decltype((arg))>
564-
|| std::
565-
is_same_v<std::monostate, std::remove_cvref_t<decltype(arg)>>) {
564+
|| std::same_as<std::monostate, std::remove_cvref_t<decltype(arg)>>) {
566565
throw std::logic_error("This exception is unreachable");
567566
} else {
568567
std::invoke(f, std::forward<decltype(arg)>(arg));
@@ -577,7 +576,7 @@ class Result {
577576
// compiler will compile a branch where f is invoked with an unsupported argument
578577
// type
579578
if constexpr (!Invocable<Self, F, decltype((arg))>
580-
|| std::is_same_v<std::monostate, std::remove_cvref_t<decltype(arg)>>) {
579+
|| std::same_as<std::monostate, std::remove_cvref_t<decltype(arg)>>) {
581580
throw std::logic_error("This exception is unreachable");
582581
} else {
583582
std::invoke(f, std::forward<decltype(arg)>(arg));
@@ -754,9 +753,9 @@ class Result<void, Errs...> {
754753
CallableReturnType,
755754
std::remove_cvref_t<Self>>;
756755

757-
// if there isn't an error, return the value
756+
// if there isn't an error, return
758757
if (!self.has_error()) {
759-
return ReturnType(std::forward<Self>(self).value);
758+
return ReturnType();
760759
}
761760

762761
// if the callable returns void
@@ -766,8 +765,7 @@ class Result<void, Errs...> {
766765
// compiler will compile a branch where f is invoked with an unsupported argument
767766
// type
768767
if constexpr (!Invocable<Self, F, decltype((arg))>
769-
|| std::
770-
is_same_v<std::monostate, std::remove_cvref_t<decltype(arg)>>) {
768+
|| std::same_as<std::monostate, std::remove_cvref_t<decltype(arg)>>) {
771769
throw std::logic_error("This exception is unreachable");
772770
} else {
773771
std::invoke(f, std::forward<decltype(arg)>(arg));
@@ -782,7 +780,7 @@ class Result<void, Errs...> {
782780
// compiler will compile a branch where f is invoked with an unsupported argument
783781
// type
784782
if constexpr (!Invocable<Self, F, decltype((arg))>
785-
|| std::is_same_v<std::monostate, std::remove_cvref_t<decltype(arg)>>) {
783+
|| std::same_as<std::monostate, std::remove_cvref_t<decltype(arg)>>) {
786784
throw std::logic_error("This exception is unreachable");
787785
} else {
788786
std::invoke(f, std::forward<decltype(arg)>(arg));

0 commit comments

Comments
 (0)