
I was just trying out lambda and I have a question. I have a template class Ave template<typename in_t, typename Scale> struct Ave {...} It takes a function type argument "Scale". Here's a test: typedef typeof (_1 * 0.1) some_type; some_type func (_1 * 0.1); // Ave<double, typeof (_1 * 0.1)> ave (_1 * 0.1); << this will work Ave<double, some_type> ave (func); << this will also What is the preferred way to do this without "typeof"? How do I get the type returned by the lambda expression to feed to the template Ave?

On Mar 10, 2004, at 2:10 PM, Neal D. Becker wrote:
I was just trying out lambda and I have a question.
I have a template class Ave template<typename in_t, typename Scale> struct Ave {...}
It takes a function type argument "Scale".
Here's a test:
typedef typeof (_1 * 0.1) some_type; some_type func (_1 * 0.1);
// Ave<double, typeof (_1 * 0.1)> ave (_1 * 0.1); << this will work Ave<double, some_type> ave (func); << this will also
What is the preferred way to do this without "typeof"? How do I get the type returned by the lambda expression to feed to the template Ave?
There is no direct way of getting to the type. One can store a lambda expression into a boost::function, for which you have to specify the return and argument types: boost::function<double (double)> func = _1 * 0.1; Cheers, Jaakko
participants (2)
-
Jaakko Jarvi
-
Neal D. Becker