Skip to content

Commit

Permalink
Some trivial cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jfalcou committed Oct 3, 2023
1 parent 1ffc96c commit d08f867
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 30 deletions.
2 changes: 1 addition & 1 deletion include/eve/traits/overload/default_behaviors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace eve
//! @addtogroup extensions
//! @{
//! @struct constant
//! @brief CRTP base class imbuing a eve::callable with a constant function semantic
//! @brief CRTP base class giving an eve::callable the constant function semantic
//!
//! Constants functions in EVE are built using a very common pattern. Inheriting from eve::constant simplifies the
//! implementation of such eve::callable by just requiring your eve::callable type to implement a static `value`
Expand Down
2 changes: 1 addition & 1 deletion include/eve/traits/overload/protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ inline constexpr auto adl_helper = adl_helper_t {}
/**/

// Flag a function to support delayed calls on given architecture
#define EVE_EXPECTS(ARCH) adl_helper_t const &, ARCH const &
#define EVE_REQUIRES(ARCH) adl_helper_t const &, ARCH const &

// Register eve::detail as the deferred namespace by default
namespace eve::detail { EVE_CALLABLE_NAMESPACE(); }
2 changes: 1 addition & 1 deletion include/eve/traits/overload/supports.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace eve::option
//! @var condition
//! @brief Keyword for retrieving conditionals decorator
//!
//! When a eve::decorated_callable is called with an option provided vi eve::conditional, the value of the
//! When a eve::decorated_callable is called with an option provided via eve::conditional, the value of the
//! conditional can be retrieved using eve::condition
//! @see eve::supports
//! @}
Expand Down
8 changes: 4 additions & 4 deletions test/doc/traits/callable_constant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ namespace eve
template<typename T> static constexpr auto value(auto, eve::as<T>) { return T{3.14159216}; }

EVE_CALLABLE_OBJECT(pi_t, pi_);
} inline constexpr Pi;
} inline constexpr some_pi;
};

int main()
{
std::cout << eve::Pi(eve::as(1.0)) << "\n";
std::cout << eve::Pi(eve::as<eve::wide<float>>{}) << "\n";
std::cout << eve::Pi[eve::keep_between(1,3)](eve::as<eve::wide<float>>{}) << "\n\n";
std::cout << eve::some_pi(eve::as(1.0)) << "\n";
std::cout << eve::some_pi(eve::as<eve::wide<float>>{}) << "\n";
std::cout << eve::some_pi[eve::keep_between(1,3)](eve::as<eve::wide<float>>{}) << "\n\n";


std::cout << "Pi(int) does not compile: "
Expand Down
4 changes: 2 additions & 2 deletions test/doc/traits/callable_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ namespace eve
// As func_t used EVE_CALLABLE_OBJECT, we should write overloads in eve::detail
namespace eve::detail
{
auto func_(EVE_EXPECTS(cpu_), eve::integral_value auto x) { return x*x; }
auto func_(EVE_EXPECTS(cpu_), double x) { return 1./x; }
auto func_(EVE_REQUIRES(cpu_), eve::integral_value auto x) { return x*x; }
auto func_(EVE_REQUIRES(cpu_), double x) { return 1./x; }
}

int main()
Expand Down
4 changes: 2 additions & 2 deletions test/doc/traits/callable_object_from.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ namespace my_lib
// As func_t used EVE_CALLABLE_OBJECT_FROM, we can write overloads in this namespace
namespace impl
{
auto func_(EVE_EXPECTS(eve::cpu_), eve::integral_value auto x) { return x*x; }
auto func_(EVE_EXPECTS(eve::cpu_), double x) { return 1./x; }
auto func_(EVE_REQUIRES(eve::cpu_), eve::integral_value auto x) { return x*x; }
auto func_(EVE_REQUIRES(eve::cpu_), double x) { return 1./x; }
}
}

Expand Down
33 changes: 15 additions & 18 deletions test/doc/traits/callable_specs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,17 @@

namespace eve
{
namespace option
{
// Defines two RABERU flags
using namespace rbr::literals;
inline constexpr auto precise = "precise"_fl;
inline constexpr auto scale = "scale"_kw;
}
// Defines two RABERU flags
using namespace rbr::literals;
inline constexpr auto precise = "precise"_fl;
inline constexpr auto scale = "scale"_fl;

// Defines a support specification
struct precision
{
auto operator[](rbr::concepts::exactly<option::precise> auto const&) -> void;
auto operator[](rbr::concepts::exactly<option::scale> auto const&) -> void;
EVE_FORCEINLINE static constexpr auto defaults() noexcept { return options{option::scale = 1.}; }
auto operator[](rbr::concepts::exactly<precise> auto const&) -> void;
auto operator[](rbr::concepts::exactly<scale> auto const&) -> void;
EVE_FORCEINLINE static constexpr auto defaults() noexcept { return options{}; }
};

// Make this callable supports the precision options
Expand All @@ -33,19 +30,19 @@ namespace eve
namespace eve::detail
{
template<typename D>
auto func_(EVE_EXPECTS(cpu_), eve::options<D> const& opt, int x)
auto func_(EVE_REQUIRES(cpu_), eve::options<D> const& opt, int x)
{
// We retrieve the option's value via the RABERU settings interface
return x * opt[option::scale] * (opt[option::precise] ? 3.14159 : 3.14);
return x * (opt[scale] ? 10. : 1.)
+ (opt[precise] ? 3.14159 : 3.14);
}
}

int main()
{
using namespace eve::option;
std::cout << eve::func(1) << "\n";
std::cout << eve::func[precise](1) << "\n";
std::cout << eve::func[scale = -.1](1) << "\n";
std::cout << eve::func[scale = 10.][precise](1) << "\n";
std::cout << eve::func[precise][scale = -1.5](1) << "\n";
std::cout << eve::func(1) << "\n";
std::cout << eve::func[eve::precise](1) << "\n";
std::cout << eve::func[eve::scale](1) << "\n";
std::cout << eve::func[eve::scale][eve::precise](1) << "\n";
std::cout << eve::func[eve::precise][eve::scale](1) << "\n";
}
2 changes: 1 addition & 1 deletion test/doc/traits/callable_supports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace eve::detail
{
// Decorated callable takes a decorators parameter first
template<typename D>
auto func_(EVE_EXPECTS(cpu_), eve::options<D> opts, eve::integral_value auto x)
auto func_(EVE_REQUIRES(cpu_), eve::options<D> opts, eve::integral_value auto x)
{
// See RABERU documentation to check and access options inside a decorator.
auto const mask = opts[option::condition];
Expand Down

0 comments on commit d08f867

Please sign in to comment.