Question

I'm running into extremely frustrating problems with Boost.

When I try running something as simple as

#include <boost/function.hpp>
#include <boost/lambda/core.hpp>
#include <boost/lambda/bind.hpp>
#include <boost/lambda/lambda.hpp>
#include <boost/array.hpp>

int main()
{
    boost::function<size_t(boost::array<size_t, 1>, size_t)> f =
        boost::lambda::_1[boost::lambda::_2];
    return 0;
}

I get back:

error C2440: 'return' :
    cannot convert from 'boost::lambda::detail::unspecified' to 'size_t'

Why is this error occurring, and how do I make Boost.Lambda do what I need?

(Yes, I'm aware I can use Boost.Phoenix et al. too, but that's not the point of the question.)

Was it helpful?

Solution

subscript operator in boost::lambda supports only the following types (from lambda/detail/operator_return_type_traits.hpp of my install of boost 1.53):

A*, A[N], std::map, std::multimap, std::deque, std::vector, std::basic_string. Everything else becomes detail::unspecified, which you see in your compiler diagnostic.

To make boost.lambda do what you need, you can submit a patch to operator_return_type_traits.hpp adding support for boost::array

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top