unique_ptr在eclipse中自动完成 [英] unique_ptr autocomplete in eclipse

查看:356
本文介绍了unique_ptr在eclipse中自动完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在玩unique_ptr。在我的最后一篇文章中,人们帮助我编译了一个使用此指针的程序,方法是指定-std = c ++ 0x在编译期间。
现在我想知道是否有任何方法来指示eclipse在自动完成时考虑c ++ 11?

unique_ptr不会出现在std ::命名空间的列表中,也不能找到与unique_ptr相关联的方法(重置,移动...)。



谢谢
vahid

= 201103L)。



正如其他人提到的,用-std = c ++ 0x或更高版本编译c ++标准(-std = c ++ 11或-std = c ++ 14)解决编译错误,但不解决eclipse索引和自动完成问题



为了解决eclipse索引问题,我将__cplusplus预处理器宏添加到项目构建属性中,值为201103L,然后刷新索引;



要添加预处理器宏:



在项目浏览器上右键单击项目>>属性>> C / C ++通用>>预处理器包括>>条目>> GNU C ++ >> CDT用户设置条目>>添加... >>预处理器宏



然后条目a名称为__cplusplus和值201103L的宏;



之后,要刷新索引,请执行:



项目浏览器上的右键项目>> >>索引>>重建;



Ps:我使用gcc 4.9.2和eclipse Luna在ubuntu 15.04 64bits


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

这篇关于unique_ptr在eclipse中自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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