7#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_MATH_ABS_CPO_HPP_
8#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_MATH_ABS_CPO_HPP_
17#include "arene/base/stdlib_choice/declval.hpp"
18#include "arene/base/stdlib_choice/enable_if.hpp"
36auto abs(U) -> U =
delete;
43template <
typename T,
typename = constra
ints<>>
44constexpr bool has_member_abs_v{
false};
49constexpr bool has_member_abs_v<T, constraints<decltype(std::declval<T const&>().abs())>>{
true};
53template <
typename T,
typename = constra
ints<>>
54constexpr bool has_adl_abs_v{
false};
59constexpr bool has_adl_abs_v<T, constraints<decltype(abs(std::declval<T const&>()))>>{
true};
68 template <
typename T, constra
ints<std::enable_if_t<has_member_abs_v<T>>> =
nullptr>
70 ->
decltype(value.abs()) {
78 template <
typename T, constra
ints<std::enable_if_t<!has_member_abs_v<T> && has_adl_abs_v<T>>> =
nullptr>
80 ->
decltype(
abs(value)) {
91 constexpr auto operator()(T
const& value)
const noexcept ->
decltype(
::arene::base::abs(value)) {
92 return ::arene::base::abs(value);
#define ARENE_CPP14_INLINE_VARIABLE(type, name)
Emulates C++17's inline variable declarations for function objects.
Definition cpp14_inline.hpp:69
Definition abs_cpo.hpp:26
Definition accumulate.hpp:37
constexpr auto abs(Number value) noexcept -> Number
Calculate the absolute value of a number.
Definition abs.hpp:46
typename constraints_impl::constraints< EnableIfs... >::type constraints
Helper used to express template constraints in a consistent way using std::enable_if_t.
Definition constraints.hpp:51
Definition accumulate.hpp:36
typename enable_if< Condition, Type >::type enable_if_t
Type alias to support constraining templates. Is an alias for the specified type if the Condition is ...
Definition enable_if.hpp:41
auto declval() noexcept -> T &&
A dummy function that is declared but not defined, with a user-specified return type,...