
The Boost reference states that boost::ref can be used to pass an argument to statechart::fifo_scheduler::create_processor by reference instead of by value. I haven't been able to get this to work if the argument type derives from boost::noncopyable. It appears that the create_processor implementation instantiates code that attempts to copy the argument. Here's an example. Note that this compiles and runs sucessfully if Object does not derive from boost::noncopyable. Thanks, Steve Hawkes ---- #include <boost/statechart/asynchronous_state_machine.hpp> #include <boost/statechart/fifo_scheduler.hpp> #include <boost/statechart/simple_state.hpp> #include <boost/noncopyable.hpp> #include <boost/ref.hpp> #include <iostream> class Object : public boost::noncopyable { }; struct Initial; struct Test : boost::statechart::asynchronous_state_machine<Test, Initial> { public: Test(my_context ctx, Object& arg1) : my_base(ctx) { } }; struct Initial : boost::statechart::simple_state<Initial, Test> { }; int main() { Object value; boost::statechart::fifo_scheduler<> scheduler; const boost::statechart::fifo_scheduler<>::processor_handle processor1 = scheduler.create_processor <Test, Object&> (boost::ref(value)); return (0); } ---- Here's the compiler error: ---- g++ -Wall -lboost_system-mt -lboost_thread-mt -o test test.cc /usr/include/boost/noncopyable.hpp: In copy constructor 'Object::Object(const Object&)': test.cc:9: instantiated from 'typename boost::statechart::processor_container<boost::statechart::fifo_scheduler <FifoWorker, Allocator>, typename FifoWorker::work_item, Allocator>::processor_handle boost::statechart::fifo_scheduler<FifoWorker, Allocator>::create_processor(Arg1) [with Processor = Test, Arg1 = Object&, FifoWorker = boost::statechart::fifo_worker<std::allocator<void> >, Allocator = std::allocator<void>]' test.cc:36: instantiated from here /usr/include/boost/noncopyable.hpp:27: error: 'boost::noncopyable_::noncopyable::noncopyable(const boost::noncopyable_::noncopyable&)' is private test.cc:9: error: within this context /usr/include/boost/statechart/fifo_scheduler.hpp: In member function 'typename boost::statechart::processor_container<boost::statechart::fifo_scheduler <FifoWorker, Allocator>, typename FifoWorker::work_item, Allocator>::processor_handle boost::statechart::fifo_scheduler<FifoWorker, Allocator>::create_processor(Arg1) [with Processor = Test, Arg1 = Object&, FifoWorker = boost::statechart::fifo_worker<std::allocator<void> >, Allocator = std::allocator<void>]': /usr/include/boost/statechart/fifo_scheduler.hpp:63: note: synthesized method 'Object::Object(const Object&)' first required here /usr/include/boost/statechart/fifo_scheduler.hpp:63: error: initializing argument 3 of 'WorkItem boost::statechart::processor_container<Scheduler, WorkItem, Allocator>::create_processor(boost::weak_ptr<std::auto_ptr<boost::statec hart::event_processor<Scheduler> > >&, Scheduler&, Arg1) [with Processor = Test, Arg1 = Object, Scheduler = boost::statechart::fifo_scheduler<boost::statechart::fifo_worker<std::al locator<void> >, std::allocator<void> >, WorkItem = boost::function0<void>, Allocator = std::allocator<void>]'