add BinaryNegate and UnaryNegate

master
Daniel Kolesa 2015-04-18 02:50:20 +01:00
parent c147f57588
commit 6247093ad9
1 changed files with 28 additions and 0 deletions

View File

@ -51,6 +51,34 @@ namespace octa {
typedef T result;
};
};
template<typename T> struct BinaryNegate {
struct type {
typedef typename T::type::first first;
typedef typename T::type::second second;
typedef bool result;
};
explicit BinaryNegate(const T &f): p_fn(f) {}
bool operator()(const typename type::first &x,
const typename type::second &y) {
return !p_fn(x, y);
}
private:
T p_fn;
};
template<typename T> struct UnaryNegate {
struct type {
typedef typename T::type::argument argument;
typedef bool result;
};
explicit UnaryNegate(const T &f): p_fn(f) {}
bool operator()(const typename type::argument &x) {
return !p_fn(x);
}
private:
T p_fn;
};
}
#endif