<Update> As usual for me, the question was wrong. The actual question is: why does transform_iterator not use the usual result_of <> metafunction to determine the type of the return value, and not directly access UnaryFunc :: result_type. Wrote an answer with work. </ Update>
In particular, is there a way to make the phoenix expression express the type result_typeas expected for the concept of std :: unary_function? boost :: transform_iterator seems to be expecting this, and looking at src I don't see a simple job.
Here is some code that reproduces the problem I encountered:
#include <boost/iterator/transform_iterator.hpp>
#include <boost/spirit/home/phoenix.hpp>
#include <numeric>
#include <iostream>
using namespace boost::phoenix;
using namespace boost::phoenix::arg_names;
int main(void){
int i[] = {4,2,5,3};
std::cout <<
std::accumulate(
boost::make_transform_iterator(i, _1*_1),
boost::make_transform_iterator(i+4, _1*_1),
0
) << std::endl;
return 0;
}
(gcc 4.3.4, boost 1.43):
/usr/include/boost/iterator/transform_iterator.hpp:43: error: no type named ‘result_type’ in ‘struct boost::phoenix::actor<...
boost:: lambda ( result_type). , make_transform_iterator , , .
- phoenix , result_type?