1#ifndef NEFORCE_CORE_FUNCTIONAL_FUNCTOR_HPP__
2#define NEFORCE_CORE_FUNCTIONAL_FUNCTOR_HPP__
12NEFORCE_BEGIN_NAMESPACE__
34template <
typename Arg,
typename Result>
49template <
typename Arg1,
typename Arg2,
typename Result>
73template <
typename T =
void>
75 NEFORCE_NODISCARD
constexpr T operator()(
const T& x,
const T& y)
const
86 using is_transparent = void;
88 template <
typename T1,
typename T2>
89 NEFORCE_NODISCARD
constexpr auto operator()(T1&& x, T2&& y)
const
90 noexcept(
noexcept(
static_cast<T1&&
>(x) +
static_cast<T2&&
>(y)))
91 ->
decltype(
static_cast<T1&&
>(x) +
static_cast<T2&&
>(y)) {
92 return static_cast<T1&&
>(x) +
static_cast<T2&&
>(y);
104template <
typename T =
void>
106 NEFORCE_NODISCARD
constexpr T operator()(
const T& x,
const T& y)
const
117 using is_transparent = void;
119 template <
typename T1,
typename T2>
120 NEFORCE_NODISCARD
constexpr auto operator()(T1&& x, T2&& y)
const
121 noexcept(
noexcept(
static_cast<T1&&
>(x) -
static_cast<T2&&
>(y)))
122 ->
decltype(
static_cast<T1&&
>(x) -
static_cast<T2&&
>(y)) {
123 return static_cast<T1&&
>(x) -
static_cast<T2&&
>(y);
134template <
typename T =
void>
136 NEFORCE_NODISCARD
constexpr T operator()(
const T& x,
const T& y)
const
147 using is_transparent = void;
149 template <
typename T1,
typename T2>
150 NEFORCE_NODISCARD
constexpr auto operator()(T1&& x, T2&& y)
const
151 noexcept(
noexcept(
static_cast<T1&&
>(x) *
static_cast<T2&&
>(y)))
152 ->
decltype(
static_cast<T1&&
>(x) *
static_cast<T2&&
>(y)) {
153 return static_cast<T1&&
>(x) *
static_cast<T2&&
>(y);
164template <
typename T =
void>
166 NEFORCE_NODISCARD
constexpr T operator()(
const T& x,
const T& y)
const
177 using is_transparent = void;
179 template <
typename T1,
typename T2>
180 NEFORCE_NODISCARD
constexpr auto operator()(T1&& x, T2&& y)
const
181 noexcept(
noexcept(
static_cast<T1&&
>(x) /
static_cast<T2&&
>(y)))
182 ->
decltype(
static_cast<T1&&
>(x) /
static_cast<T2&&
>(y)) {
183 return static_cast<T1&&
>(x) /
static_cast<T2&&
>(y);
194template <
typename T =
void>
196 NEFORCE_NODISCARD
constexpr T operator()(
const T& x,
const T& y)
const
207 using is_transparent = void;
209 template <
typename T1,
typename T2>
210 NEFORCE_NODISCARD
constexpr auto operator()(T1&& x, T2&& y)
const
211 noexcept(
noexcept(
static_cast<T1&&
>(x) %
static_cast<T2&&
>(y)))
212 ->
decltype(
static_cast<T1&&
>(x) %
static_cast<T2&&
>(y)) {
213 return static_cast<T1&&
>(x) %
static_cast<T2&&
>(y);
224template <
typename T =
void>
226 NEFORCE_NODISCARD
constexpr T operator()(
const T& x)
const noexcept(
noexcept(_NEFORCE
declcopy<T>(-x))) {
236 using is_transparent = void;
238 template <
typename T1>
239 NEFORCE_NODISCARD
constexpr auto operator()(T1&& x)
const noexcept(
noexcept(-
static_cast<T1&&
>(x)))
240 ->
decltype(-
static_cast<T1&&
>(x)) {
241 return -
static_cast<T1&&
>(x);
260template <
typename T =
void>
262 NEFORCE_NODISCARD
constexpr bool operator()(
const T& x,
const T& y)
const
273 using is_transparent = void;
275 template <
typename T1,
typename T2>
276 NEFORCE_NODISCARD
constexpr auto operator()(T1&& x, T2&& y)
const
277 noexcept(
noexcept(
static_cast<T1&&
>(x) ==
static_cast<T2&&
>(y)))
278 ->
decltype(
static_cast<T1&&
>(x) ==
static_cast<T2&&
>(y)) {
279 return static_cast<T1&&
>(x) ==
static_cast<T2&&
>(y);
290template <
typename T =
void>
292 NEFORCE_NODISCARD
constexpr bool operator()(
const T& x,
const T& y)
const
303 using is_transparent = void;
305 template <
typename T1,
typename T2>
306 NEFORCE_NODISCARD
constexpr auto operator()(T1&& x, T2&& y)
const
307 noexcept(
noexcept(
static_cast<T1&&
>(x) !=
static_cast<T2&&
>(y)))
308 ->
decltype(
static_cast<T1&&
>(x) !=
static_cast<T2&&
>(y)) {
309 return static_cast<T1&&
>(x) !=
static_cast<T2&&
>(y);
320template <
typename T =
void>
322 NEFORCE_NODISCARD
constexpr bool operator()(
const T& x,
const T& y)
const
333 using is_transparent = void;
335 template <
typename T1,
typename T2>
336 NEFORCE_NODISCARD
constexpr auto operator()(T1&& x, T2&& y)
const
337 noexcept(
noexcept(
static_cast<T1&&
>(x) >
static_cast<T2&&
>(y)))
338 ->
decltype(
static_cast<T1&&
>(x) >
static_cast<T2&&
>(y)) {
339 return static_cast<T1&&
>(x) >
static_cast<T2&&
>(y);
350template <
typename T =
void>
352 NEFORCE_NODISCARD
constexpr bool operator()(
const T& x,
const T& y)
const
363 using is_transparent = void;
365 template <
typename T1,
typename T2>
366 NEFORCE_NODISCARD
constexpr auto operator()(T1&& x, T2&& y)
const
367 noexcept(
noexcept(
static_cast<T1&&
>(x) <
static_cast<T2&&
>(y)))
368 ->
decltype(
static_cast<T1&&
>(x) <
static_cast<T2&&
>(y)) {
369 return static_cast<T1&&
>(x) <
static_cast<T2&&
>(y);
380template <
typename T =
void>
382 NEFORCE_NODISCARD
constexpr bool operator()(
const T& x,
const T& y)
const
393 using is_transparent = void;
395 template <
typename T1,
typename T2>
396 NEFORCE_NODISCARD
constexpr auto operator()(T1&& x, T2&& y)
const
397 noexcept(
noexcept(
static_cast<T1&&
>(x) >=
static_cast<T2&&
>(y)))
398 ->
decltype(
static_cast<T1&&
>(x) >=
static_cast<T2&&
>(y)) {
399 return static_cast<T1&&
>(x) >=
static_cast<T2&&
>(y);
410template <
typename T =
void>
412 NEFORCE_NODISCARD
constexpr bool operator()(
const T& x,
const T& y)
const
423 using is_transparent = void;
425 template <
typename T1,
typename T2>
426 NEFORCE_NODISCARD
constexpr auto operator()(T1&& x, T2&& y)
const
427 noexcept(
noexcept(
static_cast<T1&&
>(x) <=
static_cast<T2&&
>(y)))
428 ->
decltype(
static_cast<T1&&
>(x) <=
static_cast<T2&&
>(y)) {
429 return static_cast<T1&&
>(x) <=
static_cast<T2&&
>(y);
450 template <
typename U = T>
451 NEFORCE_NODISCARD
constexpr U&& operator()(U&& x)
const noexcept {
464template <
typename Pair>
466#ifdef NEFORCE_STANDARD_20
470 NEFORCE_NODISCARD
constexpr const typename Pair::first_type& operator()(
const Pair& x)
const noexcept {
482template <
typename Pair>
484#ifdef NEFORCE_STANDARD_20
488 NEFORCE_NODISCARD
constexpr const typename Pair::second_type& operator()(
const Pair& x)
const noexcept {
497NEFORCE_END_NAMESPACE__
NEFORCE_NODISCARD constexpr T && forward(remove_reference_t< T > &x) noexcept
完美转发左值
Arg1 first_argument_type
第一个参数类型
Arg2 second_argument_type
第二个参数类型