MS Visual Studio 2013 中没有 <optional> - 怎么办?

No <optional> in MS Visual Studio 2013 - what to do?

我想使用 std::experimental::optional,但 MSVS 2013 告诉我找不到 header。

std::experimental::optional originates from the Boost.Optional library, and this implementation works well in Visual C++ 12.0 (though it differs a little). Reference single-header implementation, based on the N3793 proposal paper, can be found here.

可从 Visual C++ Team blog, from this post in particular. A set of header files of the Standard Library implementation (and some extensions) from Microsoft can be viewed here.

中找到 Visual Studio 附带的受支持的 C++11/14/1z 核心和库功能的最新列表

我发现此实现使用 MSVC2013 进行编译。请注意,仅编译,不能保证其他所有内容。

https://github.com/mapbox/variant/blob/master/include/mapbox/optional.hpp

我在 msvc2015 中使用了这个并且它有效:

https://raw.githubusercontent.com/akrzemi1/Optional/master/optional.hpp