Boost logo

Boost Users :

From: Sebastian Weber (sebastian.weber_at_[hidden])
Date: 2006-10-23 12:59:50


Hello there!

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 error message is something like

/home/sweber/graphpkg/libs/boost/boost/function/function_template.hpp:119: error: invalid
   initialization of reference of type 'size_t&' from expression of type
'const
   unsigned int'

My system is a debian sarge with a g++-3.3 and boost 1.33.1.

What I'm trying to do is to shift the index of the data-vector such that
index 3 would address the first element.

Thanks for any help.

Greetings,

Sebastian Weber


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