Skip to content

Commit a8150db

Browse files
committed
remove sentinel trait
1 parent 0d7901f commit a8150db

File tree

2 files changed

+4
-29
lines changed

2 files changed

+4
-29
lines changed

include/common/result.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ class Result {
4545
* @param error Error to store.
4646
* @note Requires T to have a defined sentinel value (via SentinelValue<T>).
4747
*/
48-
template<traits::IsResultError E>
49-
requires traits::InPack<E, Errs...>
50-
constexpr Result(E&& error)
48+
template<typename U, traits::IsResultError E>
49+
requires std::convertible_to<U, T> && traits::InPack<E, Errs...>
50+
constexpr Result(E&& error, U&& value)
5151
: error(std::forward<E>(error)),
52-
value(traits::sentinel_v<T>) {}
52+
value(std::forward<U>(value)) {}
5353

5454
/**
5555
* @brief Get the error of the given type, wrapped in std::optional

include/common/result_impl.hpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
#include <chrono>
44
#include <concepts>
5-
#include <limits>
65
#include <stacktrace>
76
#include <variant> // IWYU pragma: keep (std::get is used, not sure why clangd says this header isn't needed)
87

@@ -103,30 +102,6 @@ concept AllUnique = ([]<typename U>(std::type_identity<U>) {
103102
template<typename T>
104103
concept IsResultError = std::is_base_of_v<ResultError, std::remove_cvref_t<T>>;
105104

106-
/**
107-
* @brief Get the defined sentinel value for a given type.
108-
*
109-
* @tparam T
110-
*/
111-
template<typename T>
112-
inline constexpr T sentinel_v;
113-
114-
template<std::integral T>
115-
inline constexpr T sentinel_v<T> = std::numeric_limits<T>::max();
116-
117-
template<std::floating_point T>
118-
inline constexpr T sentinel_v<T> =
119-
std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity()
120-
: std::numeric_limits<T>::max();
121-
122-
/**
123-
* @brief Concept to check if a type has a defined sentinel value.
124-
*
125-
* @tparam T Type to check.
126-
*/
127-
template<typename T>
128-
concept HasSentinel = requires(T) { sentinel_v<T>; };
129-
130105
/**
131106
* @brief Check whether a given type is in a typename pack
132107
*

0 commit comments

Comments
 (0)