#ifndef TCG_FUNCTIONAL_H #define TCG_FUNCTIONAL_H #include "traits.h" // std includes #include //********************************************************************************** // Logical functor combinators //********************************************************************************** namespace tcg { template class unary_and : public std::unary_function::arg_type, bool> { Fn1 m_fn1; Fn2 m_fn2; public: unary_and(const Fn1 &fn1, const Fn2 &fn2) : m_fn1(fn1), m_fn2(fn2) {} bool operator()(const typename function_traits::arg_type &t) const { return m_fn1(t) && m_fn2(t); } }; template unary_and and1(const Fn1 &fn1, const Fn2 &fn2) { return unary_and(fn1, fn2); } //---------------------------------------------------------------------------------- template class unary_or : public std::unary_function::arg_type, bool> { Fn1 m_fn1; Fn2 m_fn2; public: unary_or(const Fn1 &fn1, const Fn2 &fn2) : m_fn1(fn1), m_fn2(fn2) {} bool operator()(const typename function_traits::arg_type &t) const { return m_fn1(t) || m_fn2(t); } }; template unary_or or1(const Fn1 &fn1, const Fn2 &fn2) { return unary_or(fn1, fn2); } } // namespace tcg #endif // TCG_FUNCTIONAL_H