Boost logo

Boost Users :

From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2006-10-23 16:26:31


"Sebastian Weber" <sebastian.weber_at_[hidden]> wrote

> I'm about to explore the power of boost::bind, but I am still a
> beginner. Maybe the question is rather stupid, but the following code
> does not compile and I do not understand why:
>
> typedef std::vector<std::size_t> data_t;
>
> data_t dataVec;
>
> ... populate dataVec ...
>
> std::size_t shiftIndex = 3;
>
> boost::function<std::size_t& (std::size_t)> shiftedData =
> boost::bind(&data_t::at, &dataVec, _1 - shiftIndex);

The following should work:

boost::function<std::size_t& (std::size_t)> shiftedData =
    boost::bind(&data_t::at, &dataVec, boost::bind(std::minus<size_t>(), _1,
shiftIndex));

HTH,
Arkadiy


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net