Boost logo

Boost :

From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2002-01-29 19:40:03

David Abrahams wrote:
> I don't see how this is going to work. Once you pass a
> function pointer into a function call between parens
> (e.g. bind(&my::foo...)) it becomes a runtime
> entity, and is unavailable as a template parameter.

Oops, you are right of course. I didn't realize that non-type template
parameters cannot be deduced, e.g. that this won't work:

          typename R
        , typename T
        , R (T::*f)()
    mf0_slot<R, T, f>
    bind(f, T* obj) // declaration error
        return mf0_slot<R, T, f>(obj);

    struct my { void foo(); };

    int main()
        my m;
        function0<int> f(bind(&my::foo, &m)); // won't work

It's a shame :(. I guess, if you want this optimization, you just have to
write something like

    my m;
    function0<int> f(mf0<void, my, &my::foo>(&m));


> What am I missing?

Nothing, it's me who was thinking too fast :).


Boost list run by bdawes at, gregod at, cpdaniel at, john at