1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// Part of the BastionOS freestanding C++ standard library.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBBASTION_FUNCTIONAL_ARITHMETIC_H
#define _LIBBASTION_FUNCTIONAL_ARITHMETIC_H
#include <__config>
_LIBBASTION_BEGIN_NAMESPACE_STD
template<class _Tp = void>
struct plus {
_LIBBASTION_NODISCARD constexpr _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x + __y; }
};
template<>
struct plus<void> {
template<class _Tp, class _Up>
_LIBBASTION_NODISCARD constexpr auto operator()(_Tp&& __t, _Up&& __u) const
-> decltype(static_cast<_Tp&&>(__t) + static_cast<_Up&&>(__u))
{ return static_cast<_Tp&&>(__t) + static_cast<_Up&&>(__u); }
using is_transparent = void;
};
template<class _Tp = void>
struct minus {
_LIBBASTION_NODISCARD constexpr _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x - __y; }
};
template<>
struct minus<void> {
template<class _Tp, class _Up>
_LIBBASTION_NODISCARD constexpr auto operator()(_Tp&& __t, _Up&& __u) const
-> decltype(static_cast<_Tp&&>(__t) - static_cast<_Up&&>(__u))
{ return static_cast<_Tp&&>(__t) - static_cast<_Up&&>(__u); }
using is_transparent = void;
};
template<class _Tp = void>
struct multiplies {
_LIBBASTION_NODISCARD constexpr _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x * __y; }
};
template<>
struct multiplies<void> {
template<class _Tp, class _Up>
_LIBBASTION_NODISCARD constexpr auto operator()(_Tp&& __t, _Up&& __u) const
-> decltype(static_cast<_Tp&&>(__t) * static_cast<_Up&&>(__u))
{ return static_cast<_Tp&&>(__t) * static_cast<_Up&&>(__u); }
using is_transparent = void;
};
template<class _Tp = void>
struct divides {
_LIBBASTION_NODISCARD constexpr _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x / __y; }
};
template<>
struct divides<void> {
template<class _Tp, class _Up>
_LIBBASTION_NODISCARD constexpr auto operator()(_Tp&& __t, _Up&& __u) const
-> decltype(static_cast<_Tp&&>(__t) / static_cast<_Up&&>(__u))
{ return static_cast<_Tp&&>(__t) / static_cast<_Up&&>(__u); }
using is_transparent = void;
};
template<class _Tp = void>
struct modulus {
_LIBBASTION_NODISCARD constexpr _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x % __y; }
};
template<>
struct modulus<void> {
template<class _Tp, class _Up>
_LIBBASTION_NODISCARD constexpr auto operator()(_Tp&& __t, _Up&& __u) const
-> decltype(static_cast<_Tp&&>(__t) % static_cast<_Up&&>(__u))
{ return static_cast<_Tp&&>(__t) % static_cast<_Up&&>(__u); }
using is_transparent = void;
};
template<class _Tp = void>
struct negate {
_LIBBASTION_NODISCARD constexpr _Tp operator()(const _Tp& __x) const { return -__x; }
};
template<>
struct negate<void> {
template<class _Tp>
_LIBBASTION_NODISCARD constexpr auto operator()(_Tp&& __t) const
-> decltype(-static_cast<_Tp&&>(__t))
{ return -static_cast<_Tp&&>(__t); }
using is_transparent = void;
};
_LIBBASTION_END_NAMESPACE_STD
#endif // _LIBBASTION_FUNCTIONAL_ARITHMETIC_H
|