简体   繁体   English

使用内置的c ++结构

[英]Use built-in c++ structures

I'm working on a project using Eclipse for C++. 我正在使用Eclipse for C ++进行项目。 Currently I need to use structures such as tuples and hashes. 当前,我需要使用诸如元组和哈希的结构。 When looking for it on the cplusplus site i came with these: 在cplusplus网站上寻找它时,我附带了以下这些内容:

http://www.cplusplus.com/reference/tuple/tuple/?kw=tuple http://www.cplusplus.com/reference/tuple/tuple/?kw=tuple

The point is, following the example code on the site when trying to compile I get an error, which says, for example, that tuple is not defined. 关键是,在尝试编译时,遵循网站上的示例代码,但出现错误,例如,该错误表示未定义元组。 Looking more closely, the c++ sites says these features work on revision 11 and newer. 仔细观察,c ++站点表示这些功能适用于版本11和更高版本。 Maybe this can be my problem since I have no idea how to check my version. 也许这可能是我的问题,因为我不知道如何检查我的版本。

How do I get to work with the last revision? 我如何使用上一个修订版? I'd really help me a lot not having to implement these kind of structures from scratch. 我真的可以为我提供很多帮助,而不必从头开始实现这种结构。

EDIT: i did g++ --version on the console and got: 编辑:我做了g ++ --version在控制台上,并得到:

g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 g ++(Ubuntu / Linaro 4.6.3-1ubuntu5)4.6.3

Im using Ubuntu 12.04 with Eclipse C/C++ Kepler SR2 我在Eclipse C / C ++ Kepler SR2中使用Ubuntu 12.04

EDIT with answer: 编辑答案:

Tu use the c11 standard, gcc 4.7 is needed. 涂使用c11标准,需要gcc 4.7。 Refer to this link: http://www.swiftsoftwaregroup.com/upgrade-gcc-4-7-ubuntu-12-04/ 请参阅此链接: http : //www.swiftsoftwaregroup.com/upgrade-gcc-4-7-ubuntu-12-04/

to install it. 安装它。

compile with std=c++11 , like g++ -std=c++11 program.cpp . 使用std=c++11编译,例如g++ -std=c++11 program.cpp tuple is indeed newly introduced in C++11 , but you can use maps and sets in C++03 (the unordered versions are again a new feature of the standard library that comes with C++11 ). tuple确实是C++11新引入的,但是您可以在C++03使用mapssetsunordered版本再次是C++11随附的标准库的新功能)。 In eclipse, go to project properties, C/C++ Build/Settings/C++ compiler/Miscellaneous , then add the -std=c++11 flag 在eclipse中,转到项目属性C/C++ Build/Settings/C++ compiler/Miscellaneous ,然后添加-std=c++11标志

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM