Jump to content
  • Advertisement
Sign in to follow this  

Assignment operator/copy constructor issue with Boost.Function

This topic is 2231 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've scoured the internet for hours on this one and still cannot figure it out! Any help is appreciated.

typedef boost::function<void ()> TaskKernel;
void TaskScheduler::pushTask(const TaskData& taskData, TaskKernel kernel)
Task* task = m_taskPool->obtain();
task->m_kernel = TaskKernel(kernel);
task->m_taskData = taskData;
// later in the calling code
sch->pushTask(TaskData(), boost::bind(&run);

I get an EXC_BAD_ACCESS in boost move_assign function for the copy constructor or operator= every time. I tried passing the function without boost::bind and with all different variations. No luck...

Is there a special technique I am missing for passing boost::functions around? Edited by Craig_jb

Share this post

Link to post
Share on other sites
Perhaps try changing this:

// task->m_kernel = TaskKernel(kernel);
task->m_kernel = kernel;

I haven't looked at the latest code for boost::function, but if it's doing move-emulation for your non-C++11 compiler, that might be causing trouble. If you really need the extra copy, try copying it to a named temporary prior to the assignment (making the source of the assignment an l-value).

EDIT: perhaps you also intended to use pass-by-const-reference for the 'kernel' argument in pushTask()? Though I don't think that will cause this problem. Edited by e?dd

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!