1

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?

ildjarn
  • 62,044
  • 9
  • 127
  • 211
Gustavo Muenz
  • 9,278
  • 7
  • 40
  • 42
  • 3
    Is there a reason you're using such an ancient version of Boost? (1.37 was released in Nov. _2008_.) In any case, Boost.Lambda was officially deprecated in Boost 1.47 in favor of [Boost.Phoenix](http://www.boost.org/libs/phoenix/), and the following works fine with VC++ 2012 + Boost 1.49: http://liveworkspace.org/code/ecbc7cb9fca7680ef43236a2424c2599 – ildjarn Oct 10 '12 at 21:26
  • The reasons are that corporations are slow. I know it's old :( – Gustavo Muenz Oct 10 '12 at 21:48
  • Perhaps if you use (_1->*(&std::array::operator[]))(0)? :P – e.tadeu Oct 11 '12 at 12:55

0 Answers0