Boost logo

Boost Users :

Subject: [Boost-users] [Lambda] Using placeholders as array indices
From: user790 user790 (user790_at_[hidden])
Date: 2008-11-05 07:32:03


I am trying to use boost::lambda's placeholders as array indices. What I
tried boils down to this:

<code>

#include <vector>
#include <boost/lambda/bind.hpp>
#include <boost/lambda/lambda.hpp>

int main(int argc, char * argv[])
{
  using namespace boost::lambda;
  std::vector<int> a(10,0);
  bind(static_cast<std::vector<int>::reference
(std::vector<int>::*)(std::vector<int>::size_type)>(&std::vector<int>::operator[]),
    a, _1)(0) = 1;
}

</code>

But I get the following error (Visual C++ 2008 Express Edition, boost
1.35.0):
error C2665: 'boost::lambda::function_adaptor<Func>::apply' : none of the 2
overloads could convert all the argument types

What part am I missing?

Thanks,

P.



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