Use of custom subscript operator with Boost.Lambda

169 Views Asked by At

I'm using Visual Studio 2005 and Boost 1.37. I also tested this same code on Visual Studio 2012 Express Desktop and Boost 1.50 without success.

I want to use a Boost.Lambda by accessing a custom subscript operator on my type. It also happens when using with std::array, so I'll illustrate the problem with the std::array type:

#include <vector>
#include <array>
#include <algorithm>

int main() {
    std::vector<std::array<int, 3>> arrays;
    arrays.push_back(make_array(1, 2, 3));
    arrays.push_back(make_array(5, 5, 6));
    std::for_each(arrays.begin(), arrays.end(), (_1[0])); //This line fails!
    return 0;
}

The errors are:

error C2664: 'boost::lambda::detail::unspecified::unspecified(const boost::lambda::detail::unspecified &)' : cannot convert parameter 1 from 'int' to 'const boost::lambda::detail::unspecified &'
      Reason: cannot convert from 'int' to 'const boost::lambda::detail::unspecified'
      No constructor could take the source type, or constructor overload resolution was ambiguous
... ad infinitum...

I found this page: Extending return type deduction system

But I couldn't successfully implement it.

Does anyone know what can be done here?

0

There are 0 best solutions below