Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-08-28 09:19:23


Vladimir Prus wrote:
> Hi,
> just now I've nearly comitted the following addition to one of BGL
> headers:
>
> + struct null_property_copier {
> + template<class V1, class V2>
> + void operator()(const V1&, const V2&) const {}
> + };
> +
>
> What stopped me is that is not BGL specific at all. Is there some
> class in Boost which can be used insteead?

If you have a do-nothing nullary function:

struct do_nothing
{
    typedef void result_type;
    void operator()() const {}
};

you can build the other variations with bind(do_nothing()).

[...]

> And another question. Do we have a functional object which always
> returns true, and can be called with two arguments of any types?

If you have identity:

template<class T> struct identity
{
    typedef T result_type;
    T operator()(T const & t) { return t; }
};

you can use bind(identity<bool>(), false). With Lambda I think that you can
just use constant(false) in both cases.


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