boost::optional - rvalue references

I have been looking to optimize my code using rvalue references when they are supported; however, I currently use boost::optional which does not know how to handle / forward rvalue references. In fact even the in_place() utilities do not work to forward the rvalue into the proper constructor. My latest profiling shows that assigning a large vector to an optional is eating up 5% of my CPU time and I could replace this with a std::move() if boost::optional supported it. I have attached an updated optional.hpp with the minimum changes necessary to support the following: test v ( 99 ); test A ( 400 ); boost::optional<test> i2(std::move(v)); i2 = std::move(A); Such that if test were a vector and 99 and 400 were the sizes, the end result is v & A are of size 0 and i2 is of size 400 and no copy constructors are called (only moves). What is the plan for updating more of boost to take advantage of rvalue references?

Hi Daniel, Sorry for the late response, The extension you attached look just about right, so I will be incorporating it into the trunk this week. It won't make it into 1.45 though. Thank you for the contribution. Best -- --- Fernando Cacciola SciSoft Consulting, Founder http://www.scisoft-consulting.com
participants (2)
-
Daniel Larimer
-
Fernando Cacciola