
Le 30/06/12 06:07, Nathan Ridge a écrit :
Hi,
Some Boost.Range adaptors, such as 'transformed' or 'filtered', require a unary function. The documentation does not formally define "unary function", but it's pretty clear what it ought to be: a function (object) that's callable with one argument.
Thus, to me, the following is a perfectly valid unary function:
int foo(int a, int b = 0);
as it is callable with one argument.
However, Boost.Range does not accept such a function as an argument to 'transformed' or 'filtered'. For example, the following code:
#include<boost/range/adaptor/transformed.hpp>
int foo(int a, int b = 0);
int main() { int A[5]; A | boost::adaptors::transformed(foo); }
The following should work int unary(int a) {return foo(a)}; int main() { int A[5]; A | boost::adaptors::transformed(unary); } I agree that it will be interesting to have a way to make this bar transformation using a class template unary int main() { int A[5]; A | boost::adaptors::transformed(unary<foo>()); } Best, Vicente