[英]C++17 std::variant header file (clang 6.0.0)
Update 更新资料
I narrowed down the problem to (probably! it's not entirely clear, even reading all I could find about the topic) that installing stdlibc++-7-dev
would provide me with suitable (ie, C++17-compliant) STL headers and libraries. 我将问题缩小到(可能!还不清楚,甚至连我都可以找到的所有信息都知道),安装
stdlibc++-7-dev
可以为我提供合适的(即,兼容C ++ 17的)STL标头和库。
This (also, apparently) comes bundled with Ubuntu 17.04 ( artful
?) but is not available for xenial
(Ubuntu 16.04.3 LTS) which is what I'm using. 这个(显然也是)与Ubuntu 17.04(
artful
吗?)捆绑在一起,但是不能用于我正在使用的xenial
(Ubuntu 16.04.3 LTS)。
I have tried downloading the individual .deb
packages and installing them, but it quickly becomes a maze of unresolved dependencies. 我尝试下载单个
.deb
软件包并安装它们,但是它很快变成了无法解析的依赖关系的迷宫。
If anyone could point me to how to install libstdc++-7-dev
on 16.04, I'd be most grateful. 如果有人可以指出如何在16.04上安装
libstdc++-7-dev
,我将不胜感激。
Original question 原始问题
I have just installed clang++ 6.0 in Ubuntu 16.04 via the package manager (following these instructions ) and all seems well: /usr/bin/clang++-6.0
works just fine, and if I try to use something that only works in C++17 ( non-type template arguments with auto
, see here ) it compiles and runs, once I set CMAKE_CXX_COMPILER=/usr/bin/clang++-6.0
-- while it fails when I don't. 我刚刚通过软件包管理器在Ubuntu 16.04中安装了clang ++ 6.0(按照这些说明进行操作 ),一切似乎都很好:/
/usr/bin/clang++-6.0
clang++-6.0可以正常工作,并且如果我尝试使用仅在C ++ 17中/usr/bin/clang++-6.0
东西( non-type template arguments with auto
,请参见此处 ),一旦我设置了CMAKE_CXX_COMPILER=/usr/bin/clang++-6.0
,它就会编译并运行-但是当我不这样做时它将失败。
So... clang 6.0
understands C++17 as advertised (doh!) but when I use: 所以...
clang 6.0
C ++ 17理解为广告(doh!),但是当我使用时:
#include <variant>
the file is not found where I would expect it to be: 找不到该文件在我期望的位置:
$ ll /usr/include/clang/6.0.0/
total 0
lrwxrwxrwx 1 root root 45 Aug 6 21:32 include -> ../../../lib/llvm-6.0/lib/clang/6.0.0/include
or anywhere else I can think of. 或其他我能想到的地方。
Would anyone know (a) whether it's supposed to be there at all and (b) if so, where do I go find it? 谁会知道(a)是否应该在那里,以及(b)如果应该,我在哪里可以找到它?
Update 更新资料
I have double-checked that I have the latest (I think) stdc++
library: 我仔细检查过我是否拥有最新的(我认为)
stdc++
库:
$ sudo apt-get install libstdc++-5-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libstdc++-5-dev is already the newest version (5.4.0-6ubuntu1~16.04.4).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
and same for libstdc++-6-dev
; 与
libstdc++-6-dev
; also, I have libc++-dev
: 另外,我有
libc++-dev
:
$ sudo apt-get install libc++-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libc++-dev is already the newest version (3.7.0-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Still, the variant.h*
file is nowhere to be found. 尽管如此,
variant.h*
文件仍然找不到。 Anything else I should try? 还有什么我应该尝试的?
Yes, clang 5.0 (or rather, the libc++ that will ship as part of clang 5) has the <variant>
header. 是的,clang 5.0(或更确切地说,将作为clang 5的一部分提供的libc ++)具有
<variant>
标头。 But you need to be sure that you have installed libc++. 但是,您需要确保已安装libc ++。
And as @KayEss mentioned, you'll need to pass -std=c++17
(or the earlier version of the same flag -std=c++1z
) because variant is a C++17-only feature. 就像@KayEss提到的那样,您需要传递
-std=c++17
(或相同标志-std=c++1z
的早期版本),因为variant是仅C ++ 17的功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.