Boost logo

Boost :

From: Matthias Troyer (troyer_at_[hidden])
Date: 2003-04-05 05:40:09


Dear Boosters,

Mario Rueti, a student in my group, needed and wrote the following
function objects which seem to be missing in the standard library (only
arithmetic and logical operations seem to be defined as function
objects). Since these might be of more general interest we wonder if
they might fit into boost, e.g. into functional.hpp ?

Matthias

namespace boost {
// definition of function objects not defined by STL
template <class T>
struct bit_and : public binary_function<T,T,T>
{
   T operator()(const T& x, const T& y) const { return x & y; }
};

template <class T>
struct bit_or : public binary_function<T,T,T>
{
   T operator()(const T& x, const T& y) const { return x | y; }
};

template <class T>
struct bit_xor : public binary_function<T,T,T>
{
   T operator()(const T& x, const T& y) const { return x ^ y; }
};

template <class T>
struct bit_not : public unary_function<T,T>
{
   T operator()(const T& x) const { return ~x; }
};
}


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk