Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SadiinsoSnowfall committed Feb 14, 2025
1 parent 8721615 commit f5db326
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
28 changes: 25 additions & 3 deletions include/eve/concept/generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,34 @@ namespace eve
//! @concept generator
//! The concept `generator<Constant>` is satisfied if `Constant` is built as a eve::constant_callable.
//!
//! @tparam G Type of the generator to check.
//!
//! @groupheader{Examples}
//! - `eve::one`
//! - `eve::one_t`
//====================================================================================================================
template<typename Constant>
concept generator = requires { typename Constant::constant_callable_tag; };
//================================================================================================
//====================================================================================================================
//! @}
//====================================================================================================================

//====================================================================================================================
//! @ingroup simd_concepts
//! @{
//! @concept generator_from
//! The concept `generator_for` is satisfied if `G` satisfies eve::generator and can be called with a
//! `eve::as<T>` argument.
//!
//! @tparam G Type of the generator to check.
//! @tparam T Type of the argument to pass to the generator.
//!
//! @groupheader{Examples}
//! - `eve::one_t` satisfies `generator_for<int>`
//! - `eve::nbmantissabits_t` satisfies `generator_for<float>` but not `generator_for<int>`
//====================================================================================================================
template<typename G, typename T>
concept generator_for = generator<G> && requires(G g, as<T> t) { g(t); };
//====================================================================================================================
//! @}
//================================================================================================
//====================================================================================================================
}
4 changes: 2 additions & 2 deletions include/eve/concept/substitute.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ namespace eve
//! @brief Specify that a type can be used as a substitute for another type after calling
//! `eve::as_value` on a value of the first type.
//================================================================================================
template<typename T, typename Target>
concept substitute_for = ((arithmetic_value<T> || relaxed_logical_value<T>) && requires { Target{std::declval<T>()}; }) || generator<T>;
template<typename S, typename Target>
concept substitute_for = generator_for<S, Target> || ((arithmetic_value<S> || relaxed_logical_value<S>) && requires(S s) { Target{s}; });
//================================================================================================
//! @}
//================================================================================================
Expand Down
6 changes: 3 additions & 3 deletions test/unit/api/tuple/algorithm/scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ TTS_CASE("Check return type of scan on tuples")
{
using w_t = eve::wide<kumi::tuple<char, int, double>>;
auto plus = [](auto a, auto b) {
return w_t{ kumi::map(eve::add, a, b) };
return kumi::map(eve::add, a, b);
};

TTS_EXPR_IS((eve::scan(std::declval<w_t>(), plus, eve::zero)), w_t);
Expand All @@ -41,7 +41,7 @@ TTS_CASE_TPL( "Check behavior of scan", eve::test::scalar::all_types)
w_t expected = kumi::map(eve::scan, x);

auto plus = [](auto a, auto b) {
return w_t{ kumi::map(eve::add, a, b) };
return kumi::map(eve::add, a, b);
};

w_t actual_1 = eve::scan(x, plus, eve::zero);
Expand Down Expand Up @@ -70,7 +70,7 @@ TTS_CASE_TPL( "Check behavior of scan, same type", eve::test::scalar::all_types)
w_t expected = kumi::map(eve::scan, x);

auto plus = [](auto a, auto b) {
return w_t{ kumi::map(eve::add, a, b) };
return kumi::map(eve::add, a, b);
};

w_t actual_1 = eve::scan(x, plus, eve::zero);
Expand Down

0 comments on commit f5db326

Please sign in to comment.