Boost logo

Boost Users :

Subject: [Boost-users] nested bind() does not compile
From: Serguei Kolos (Serguei.Kolos_at_[hidden])
Date: 2010-07-14 04:57:20


I'm wondering why the attached code which is using nested boost::bind()
does not compile on GCC ( I have tried 4.1 and 4.3). According to the
"bind" package documentation nested bind() calls are allowed.
To make it compile (and work!) it's necessary to add explicit cast to the
result of the nested bind() call, like:

boost::function<void ( void )> f =
        boost::bind( wrapper, a, (boost::function<bool
(void)>)boost::bind( cb, p ), b );

But that is something which I don't like.
Any ideas?


#include <boost/bind.hpp>
#include <boost/function.hpp>

typedef bool (*Callback)( void * );

void wrapper( int , boost::function<bool (void)> , int ) { }

bool callback( void * ) { }

void test( Callback c, void * p ) {
    int a,b;

    boost::function<void ( void )> f =
        boost::bind( wrapper, a, boost::bind( c, p ), b );

int main() {
    test( callback, 0 );

    return 0;

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at