std可选:无此类文件或目录 [英] std optional: No such file or directory

查看:262
本文介绍了std可选:无此类文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用不同的编译器(包括gcc 6.1)编译以下程序:

I tried to compile the following program with different compilers (including gcc 6.1) :

#include <optional>
int main()
{
    std::optional<int> o1;
}

输出为

main.cpp:1:20:致命错误:可选:没有这样的文件或目录#include可选

main.cpp:1:20: fatal error: optional: No such file or directory #include optional

对于此处给出的示例,这甚至是正确的: http://en.cppreference.com/w/cpp/utility/optional/optional

This is even true for the examples given here: http://en.cppreference.com/w/cpp/utility/optional/optional

任何线索为何?

推荐答案

std::optional将成为C ++ 17标准的一部分,但如果要在此之前使用,则必须使用std::experimental::optional代替在标题<experimental/optional>中.

std::optional will be part of the C++17 standard, but if you want to use before then you will have to use std::experimental::optional instead, available in the header <experimental/optional>.

这篇关于std可选:无此类文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆