Boost logo

Boost Users :

From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2007-05-30 03:28:05


Well,

if you switch to functors, instead of functions I can offer you the following example ;) But I am
unsure if it really suits your needs.

#include <iostream>

template<class T>
struct function_template
{
        void operator()(T value)const
        {
                std::cout << value << std::endl;
        }
};

template<class T>
struct other_function_template
{
        void operator()(T value)const
        {
                std::cout << value*value << std::endl;
        }
};

struct function_template_wrapper
{
        template<class T, template<class> class Function>
        static inline void call(T value, Function<T> f = Function<T>())
        {
                f(value);
        }
};

int main(int argc, char* argv[])
{

        function_template_wrapper::call<int, function_template>(10);

        other_function_template<int> of;
        function_template_wrapper::call(10, of);
}

On Wed, May 30, 2007 08:54, Ares Lagae wrote:
>
> my closest attempt is this:
>
[...]
> --
> Ares Lagae
> Computer Graphics Research Group, Katholieke Universiteit Leuven
> http://www.cs.kuleuven.be/~ares/
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

With Kind Regards,

Ovanes Markarian


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net