Is it possible to move a boost::optional?

后端 未结 3 783
误落风尘
误落风尘 2021-01-07 17:26

I\'ve been trying to define a defaulted move constructor in a class with a boost::optional member variable.

#include 
         


        
3条回答
  •  一个人的身影
    2021-01-07 17:55

    It's not clear how high on the agenda C++11 feature support for boost::optional is.

    I found a nice fellow on the Internet who gave me some of his own code under a boost license...which is still undergoing some tweaks. It's at a point where it works for me. Maybe it will help anyone looking at this question:

    https://github.com/hostilefork/CopyMoveConstrainedOptional

    There is also a larger group effort to define a std::optional which has been going on...but their reference implementation wasn't able to handle some of the cases I had:

    http://kojot.sggw.waw.pl/~akrzemi1/optional/tr2.optional.proposal.html

提交回复
热议问题