-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctors.hpp
45 lines (41 loc) · 921 Bytes
/
functors.hpp
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
#ifndef ryk_functors
#define ryk_functors
namespace ryk {
template<class T, class V>
struct add
{
using result_type = decltype(operator()(std::declval<T&>(), std::declval<V&>()));
constexpr auto operator()(const T& t, const V& v)
{
return t + v;
}
};
template<class T, class V>
struct subtract
{
using result_type = decltype(operator()(std::declval<T&>(), std::declval<V&>()));
constexpr auto operator()(const T& t, const V& v)
{
return t - v;
}
};
template<class T, class V>
struct multiply
{
using result_type = decltype(operator()(std::declval<T&>(), std::declval<V&>()));
constexpr auto operator()(const T& t, const V& v)
{
return t * v;
}
};
template<class T, class V>
struct divide
{
using result_type = decltype(operator()(std::declval<T&>(), std::declval<V&>()));
constexpr auto operator()(const T& t, const V& v)
{
return t / v;
}
};
} // namespace ryk
#endif