Boost logo

Boost Users :

Subject: [Boost-users] [context] Compiling error with context and bind
From: José (josessantos_at_[hidden])
Date: 2014-09-09 16:47:35


Dear all,
 
 I changed the example jump.cpp from Context library to use a class, with fcontext_t as an attribute. I wrote the code below, but I can't compile it because there is an error in the use of boost::bind.
 
 
 What can be happening?
 
 
Modified jump.cpp:
 
namespace ctx = boost::context;
 
typedef ctx::simple_stack_allocator<
    8 * 1024 * 1024, // 8MB
    64 * 1024, // 64kB
    8 * 1024 // 8kB
>       stack_allocator;
 
struct FooClass{
        ctx::fcontext_t fcm;
        ctx::fcontext_t fc1;
        void f1( intptr_t)
        {
            std::cout << "f1: entered" << std::endl;
            ctx::jump_fcontext( & fc1, fcm, 0, false);
        }
};
 
int main( int argc, char * argv[])
{
    FooClass* foo = new FooClass();
    stack_allocator alloc;
 
    void * base1 = alloc.allocate( stack_allocator::default_stacksize());
    foo->fc1 = ctx::make_fcontext( base1, stack_allocator::default_stacksize(), boost::bind(&FooClass::f1, foo, _1 ));
 
    std::cout << "main: call start_fcontext( & fcm, fc1, 0)" << std::endl;
    ctx::jump_fcontext( & foo->fcm, foo->fc1, 0, false);
 
    std::cout << "main: done" << std::endl;
 
    return EXIT_SUCCESS;
}
 
 
Regards,
Jose

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