Skip to content

Commit

Permalink
added substitute_for concept
Browse files Browse the repository at this point in the history
  • Loading branch information
SadiinsoSnowfall committed Feb 12, 2025
1 parent 4fa3833 commit dafef07
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
27 changes: 27 additions & 0 deletions include/eve/concept/substitute.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//==================================================================================================
/*
EVE - Expressive Vector Engine
Copyright : EVE Project Contributors
SPDX-License-Identifier: BSL-1.0
*/
//==================================================================================================
#pragma once

#include <concepts>
#include <eve/module/core/constant/as_value.hpp>

namespace eve
{
//================================================================================================
//! @ingroup simd_concepts
//! @{
//! @concept substitute_for
//! @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 U>
concept substitute_for = requires { as_value(T{}, as<U>{}); };
//================================================================================================
//! @}
//================================================================================================
}
3 changes: 2 additions & 1 deletion include/eve/module/core/regular/scan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
#include <eve/arch.hpp>
#include <eve/detail/overload.hpp>
#include <eve/concept/invocable.hpp>
#include <eve/concept/substitute.hpp>

namespace eve
{
template<typename Options>
struct scan_t : callable<scan_t, Options>
{
template<simd_value Wide, eve::monoid<Wide> Op, typename Zero>
template<simd_value Wide, eve::monoid<Wide> Op, eve::substitute_for<Wide> Zero>
constexpr EVE_FORCEINLINE Wide operator()(Wide w, Op op, Zero z) const noexcept
requires (requires { as_value(z, as<Wide>{}); })
{
Expand Down

0 comments on commit dafef07

Please sign in to comment.