If there is a function template: template<typename T> T f(T t); then f is not a type and cannot be passed to fusion::for_each() as the second argument. But I can't write fusion::for_each(someSequence,&f<SomeType>) either since elements of someSequence has different types. While I can write f as a functor fo struct fo{ template<typename T> T operator()(T t); }; and call fusion::for_each(someSequence,fo()), sometimes I need to use function templates in libraries ( say, I have a fusion::vector whose elements are ranges ) and the only solution seems to be writing a lot of functors to wrap the function templates. I tried to find a wrapper class template that can wrap arbitary function templates to functors in boost but I didn't find any. Then I tried to write such a wrapper using constructs like template<template<typename T0> class F>struct temp_fun_1; but the code made my MSVC2008 compiler crash(really!). Is there such a wrapper in boost or any other library, or is it even possible?
fusion::for_each is easy because the expected function only needs to return void. It gets more complex if you have to return something, e.g. fusion::fold. You really need a Polymorphic Function Object (http://tinyurl.com/3qpsrkc) with proper result_of facilities. Anything less won't cut it.
Wrapper? There's nothing close to what you want primarily due to the complexities of the return type deduction. It won't make sense to provide an easy wrapper for monomorphic return types which is only useful for for_each.
What if we use C++0x decltype for return type deduction? Is it possible then? Thanks, Nate