ztsdb
unop_binop_funcs.hpp
1 // (C) 2016 Leonardo Silvestri
2 //
3 // This file is part of ztsdb.
4 //
5 // ztsdb is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // ztsdb is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with ztsdb. If not, see <http://www.gnu.org/licenses/>.
17 
18 
19 #ifndef UNOP_BINOP_FUNCS
20 #define UNOP_BINOP_FUNCS
21 
22 #include <string>
23 #include "valuevar.hpp"
24 
25 
26 namespace funcs {
27 
29  constexpr double pow(double d1, double d2) { return std::isnan(d2) ? d2 : std::pow(d1, d2); }
30 
31  template <typename T>
32  struct power : public binary_function<T, T, T> {
33  constexpr T operator()(const T& x, const T& y) const { return pow(x, y); }
34  };
35 
37  template <typename T>
38  struct not_equal_to : public binary_function<T, T, T> {
39  constexpr bool operator()(const T& x, const T& y) const { return !(x == y); }
40  };
41 
42  val::Value evalunop(val::Value v, int op);
43  val::Value evalbinop(val::Value v1, const val::Value& v2, int op, const val::Value& attrib);
44 
45 }
46 
47 #endif
funcs::not_equal_to
Calculate not equal using negation of equality.
Definition: unop_binop_funcs.hpp:38
funcs::power
Definition: unop_binop_funcs.hpp:32