@@ -63,7 +63,7 @@ namespace traits {
6363 * @tparam Ts the typename pack to check
6464 */
6565template <typename T, typename ... Ts>
66- inline constexpr bool is_in_pack_v = (std::is_same_v<std::remove_cvref_t <T>, Ts> || ...);
66+ concept InPack = (std::is_same_v<std::remove_cvref_t <T>, Ts> || ...);
6767
6868// A simple type pack wrapper
6969template <typename ... Ts>
@@ -86,7 +86,7 @@ struct contains_all;
8686 */
8787template <typename ... As, typename ... Bs>
8888struct contains_all <type_pack<As...>, type_pack<Bs...>> {
89- static constexpr bool value = (is_in_pack_v <Bs, As...> && ...);
89+ static constexpr bool value = (InPack <Bs, As...> && ...);
9090};
9191
9292/* *
@@ -107,30 +107,11 @@ inline constexpr bool contains_all_v = contains_all<PackA, PackB>::value;
107107template <typename PackA, typename PackB>
108108concept ContainsAll = contains_all_v<PackA, PackB>;
109109
110- /* *
111- * @brief type trait for checking whether a type is derived from the ResultError class
112- */
113- template <typename >
114- struct is_result_error : std::false_type {};
115-
116- /* *
117- * @brief type trait for checking whether a type is derived from the ResultError class
118- */
119- template <typename T>
120- requires std::is_base_of_v<ResultError, T>
121- struct is_result_error <T> : std::true_type {};
122-
123- /* *
124- * @brief whether the given type is derived from the ResultError class
125- */
126- template <typename T>
127- inline constexpr bool is_result_error_v = is_result_error<T>::value;
128-
129110/* *
130111 * @brief IsResultError concept. Enforces that the given type is derived from the ResultError class
131112 */
132113template <typename T>
133- concept IsResultError = is_result_error_v< T>;
114+ concept IsResultError = std::is_base_of_v<ResultError, T>;
134115
135116/* *
136117 * @brief Trait to define a "sentinel" value for types indicating an error state.
@@ -275,17 +256,17 @@ using or_else_return_t =
275256
276257// or_else invocable callable helper
277258template <typename Self, typename F, typename E>
278- constexpr static bool invocable_v =
259+ concept Invocable =
279260 std::is_invocable<F, decltype ((std::get<E>(std::declval<Self>().error)))>::value;
280261
281262template <typename F, typename Self>
282263struct invocable_indirect_v {
283264 template <typename U>
284- static constexpr bool value = invocable_v <Self, F, U>;
265+ static constexpr bool value = Invocable <Self, F, U>;
285266};
286267
287268template <typename F, typename Self, typename ... Es>
288- concept any_invocable = (traits::invocable_v <Self, F, Es> || ...);
269+ concept any_invocable = (traits::Invocable <Self, F, Es> || ...);
289270
290271template <typename T>
291272concept ResultOrVoid =
@@ -333,7 +314,7 @@ class Result {
333314 * @note Requires T to have a defined sentinel value (via SentinelValue<T>).
334315 */
335316 template <traits::IsResultError E>
336- requires traits::is_in_pack_v <E, Errs...>
317+ requires traits::InPack <E, Errs...>
337318 constexpr Result (E&& error)
338319 : error(std::forward<E>(error)),
339320 value(traits::sentinel_v<T>) {}
@@ -347,7 +328,7 @@ class Result {
347328 * @return the error type, wrapped in std::optional
348329 */
349330 template <traits::IsResultError E, typename Self>
350- requires traits::is_in_pack_v <E, Errs...>
331+ requires traits::InPack <E, Errs...>
351332 constexpr auto get_error (this Self&& self) {
352333 if (std::holds_alternative<E>(self.error )) {
353334 return std::optional<E>(std::get<E>(std::forward<Self>(self).error ));
@@ -460,7 +441,7 @@ class Result {
460441 // even though this condition is impossible, it's necessary. Otherwise the
461442 // compiler will compile a branch where f is invoked with an unsupported argument
462443 // type
463- if constexpr (!traits::invocable_v <Self, F, decltype ((arg))>
444+ if constexpr (!traits::Invocable <Self, F, decltype ((arg))>
464445 || std::
465446 is_same_v<std::monostate, std::remove_cvref_t <decltype (arg)>>) {
466447 throw std::logic_error (" This exception is unreachable" );
@@ -474,7 +455,7 @@ class Result {
474455 // even though this condition is impossible, it's necessary. Otherwise the
475456 // compiler will compile a branch where f is invoked with an unsupported argument
476457 // type
477- if constexpr (!traits::invocable_v <Self, F, decltype ((arg))>
458+ if constexpr (!traits::Invocable <Self, F, decltype ((arg))>
478459 || std::is_same_v<std::monostate, std::remove_cvref_t <decltype (arg)>>) {
479460 throw std::logic_error (" This exception is unreachable" );
480461 } else {
@@ -546,7 +527,7 @@ class Result<void, Errs...> {
546527 * @param error Error to store.
547528 */
548529 template <traits::IsResultError E>
549- requires traits::is_in_pack_v <E, Errs...>
530+ requires traits::InPack <E, Errs...>
550531 constexpr Result (E&& error)
551532 : error(std::forward<E>(error)) {}
552533
@@ -565,7 +546,7 @@ class Result<void, Errs...> {
565546 * @return the error type, wrapped in std::optional
566547 */
567548 template <traits::IsResultError E, typename Self>
568- requires traits::is_in_pack_v <E, Errs...>
549+ requires traits::InPack <E, Errs...>
569550 constexpr auto get_error (this Self&& self) {
570551 if (std::holds_alternative<E>(self.error )) {
571552 return std::optional<E>(std::get<E>(std::forward<Self>(self).error ));
0 commit comments