----- Original Message ----- 
From: "Aleksey Gurtovoy" <[EMAIL PROTECTED]>



> My current understanding (which, admittedly, is not backed up by a
> real-world experience) is that if you care about higher-orderness of your
> generic algorithms, a preferred implementation construct for those
> algorithms is not a function template, but a static _function object_ (a
> technique used in FC++):
> 
>     struct my_function_
>     {
>         template< typename U >
>         void operator()(std::string const& text, U)
>         {
>             // ...
>         }
> 
>     } my_function; // here!
> 
> 
> For ordinary uses, the above will act just like a plain function template
> (minus ADL/explicit template arguments specification):
> 
>     my_function("text", int());
> 
> and it will also allow one to do something like this:
> 
>     std::string text("text");
>     mpl::for_each< my_types >(boost::bind<void>(my_function, text, _1));

Here's the Phoenix version:

    struct my_function_
    {

        template <typename Arg1T, typename Arg2T>
        struct result { typedef void type; };

        template< typename U >
        void operator()(std::string const& text, U)
        {
            // ...
        }

    };

    function<my_function_> my_function; // here!

Then:

    mpl::for_each< my_types >(my_function(text, _1));

Regards,
Joel de Guzman
[EMAIL PROTECTED]
http://www.boost-consulting.com






_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to