eclipse中的unique_ptr自动补全[英] unique_ptr autocomplete in eclipse



我正在玩unique_ptr.在我的上一篇文章汇编过程中的C ++ 0x. 现在,我想知道是否有任何方法可以指示Eclipse自动完成时考虑C ++ 11?
unique_ptr不在std ::名称空间的列表中,也无法找到与solution_ptr相关的方法(重置,移动...).

谢谢 Vahid


"内存"标头(可能在/usr/include/c+++/4.9/memory)中仅包括" unique_ptr.h"和" shared_ptr.h"(可能找到在/usr/user include/c ++/4.9/bits/bits/sutorical_ptr.h和/usr/include/c++/4.9/bits/shared_ptr.h)如果宏" __cplusplus"相等或英勇,而不是" 2011003L".在第69行中查看内存.

正如其他人提到的那样,使用" -std = C ++ 0x"或更高版本的C ++标准(-STD = C ++ 11或-STD = C ++ 14)求解了汇编错误,但没有Eclipse索引和索引索引和自动完成问题.

要解决日食索引问题,我在项目构建属性中添加了" __cplusplus"预处理器宏,并带有" 201103L",然后我刷新了索引;



"右键单击项目资源管理器上的项目" >>属性>> c/c ++常规>>预处理程序包括>>条目>> gnu c ++ >> cdt用户设置条目>>添加... >>添加... >>预处理器宏; <<<<<<<<<<<<<<<<<<<<<<<<<<<<

然后输入带有名称" __cplusplus"的宏和值" 201103L";


"右键单击项目资源管理器上的项目" >>索引>>重建;

ps.:我正在使用GCC 4.9.2和Eclipse Luna(4.4.2),在Ubuntu上15.04 64Bits


我想您应该在日食中将__GXX_EXPERIMENTAL_CXX0X__定义__GXX_EXPERIMENTAL_CXX0X__定义.另请参阅此问题 gnu c ++如何检查-std = c ++ 0x何时有效? a href =""> eclipse indexer无法解决shared_ptr for shared_ptr.



I am playing with unique_ptr. In my last post people helped me compiling a program that used this pointer by specifying the -std=c++0x during compilation. Now i was wondering if there is any way to instruct eclipse to consider c++11 while auto-completing?
unique_ptr is not coming in the list of std:: namespace, nor I can find the methods (reset, move...) associated with a unique_ptr.

Thank you vahid


The "memory" header (probably found at /usr/include/c++/4.9/memory) only includes "unique_ptr.h" and "shared_ptr.h" (probably found at /usr/include/c++/4.9/bits/unique_ptr.h and /usr/include/c++/4.9/bits/shared_ptr.h) if the macro "__cplusplus" is equal or greather than "201103L". Check memory.h for yourself to see the "#if" preprocessor condition there, at line 69 (or search for the string "#if __cplusplus >= 201103L").

As others mentioned, compiling with "-std=c++0x" or later c++ standards (-std=c++11 or -std=c++14) solves the compilation errors, but not the eclipse indexing and autocomplete problem.

To solve the eclipse indexing issue I added the "__cplusplus" Preprocessor Macro to the project build properties, with the value "201103L", and afterwards I refreshed the index;

To add the preprocessor macro:

"right click the project on project explorer" >> properties >> C/C++ General >> Preprocessor Includes >> Entries >> GNU C++ >> CDT User Settings Entries >> Add... >> Preprocessor Macro;

Then entry a macro with name "__cplusplus" and value "201103L";

Afterwards, to refresh the index, do:

"right click project on project explorer" >> Index >> Rebuild;

Ps.: I was using gcc 4.9.2 and eclipse Luna (4.4.2), on ubuntu 15.04 64bits


I guess you should add __GXX_EXPERIMENTAL_CXX0X__ definition to your "Paths and Symbols" in Eclipse. See also this question GNU C++ how to check when -std=c++0x is in effect? and the same question Eclipse indexer can't resolve shared_ptr for shared_ptr.