Eclipse CDT索引和std :: unique_ptr [英] Eclipse CDT indexing and std::unique_ptr

查看:279
本文介绍了Eclipse CDT索引和std :: unique_ptr的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这段代码中使用std :: unique_ptr,按照我的预期编译和运行。

I am using std::unique_ptr in this piece of code which compiles and runs as I expected.

std::stringstream out;
out << std::setw(3) << std::setfill('0') << i;
std::unique_ptr<std::string> s(new std::string(out.str()));
s->insert(s->end()-2, 1, '.');
return std::move(s);

但是,我收到来自Eclipse CDT的错误消息。在第四行:方法'insert'无法解析,方法'结束'无法解析。

However, I am getting error messages from Eclipse CDT. At the fourth line: Method 'insert' could not be resolved, Method 'end' could not be resolved.

以前,我也出现了名称的错误的std ::的unique_ptr。这通过设置预处理器符号 __ GXX_EXPERIMENTAL_CXX0X __ 并重建索引来解决,如这个问题。

Previously, I was also getting errors on appearances of the name std::unique_ptr. This was solved by setting the pre-processor symbol __GXX_EXPERIMENTAL_CXX0X__ and rebuilding the index, as described in the answer to this question.

有没有办法使CDT了解s是类型std :: string *,它应该在std :: string中查找s-> insert()和s-> end()?

Is there a way to make CDT understand that s is of type std::string * and that it should look in std::string for s->insert() and s->end() ?

PS:我正在使用Eclipse 3.7.1和CDT 8.0.0.201106081058

PS: I am using Eclipse 3.7.1 and CDT 8.0.0.201106081058

PS2:我本来希望将此作为上述问题的评论发布,但我不能,可能是因为我是一个新用户

PS2: I would have liked to post this as a comment in the above question, but I can't, presumably because I am a new user

推荐答案

好像Eclipse CDT索引器不能推导出unique_ptr ::指针类型也用作运算符的返回类型 - >()。您可以在输入类似

It seems as if the Eclipse CDT indexer is not able to deduce the unique_ptr::pointer type that is also used as the return type of operator->(). You can see this when you type something like

std::unique_ptr<Type *> ptr;
ptr.reset(new Type);

一个错误将被检测到将不存在匹配的重载,而唯一的候选人将要重置(?)。所以这显然是一个错误。

an error will be "detected" that there would be no matching overload, and that the only candidate would be reset(?). So this is obviously a bug.

这篇关于Eclipse CDT索引和std :: unique_ptr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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