boost::optional alternative in C++ Standard Library

前端 未结 3 422

I\'m trying to get my program working without boost usage, but can\'t find an alternative of some useful patterns. Namely, I can\'t find boost::optional

相关标签:
3条回答
  • 2021-01-01 13:31

    Short answer: No.

    Long answer: Roll your own according to the boost spec. The documentation is quite exhaustive and the code isn't that complex, but this still requires above average C++ skills.

    To update this answer: C++14 unfortunately did not ship with std::optional. The current proposal (Revision 5) is N3793 and it is expected to be shipped as a separate technical specification or to become part of C++17.

    0 讨论(0)
  • 2021-01-01 13:36

    Like pmr explained, it is not possible right now, and will not be until C++17 is out.

    However, you should be able to use this single header library on github as a drop in replacement of boost- or std optional. It has no dependencies (except a c++11/c++14 capable compiler).

    0 讨论(0)
  • 2021-01-01 13:56

    There is currently a proposal for C++14 (or C++17). So the answer is (probably) not yet :).

    0 讨论(0)
提交回复
热议问题