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

查看:238
本文介绍了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'无法解析,方法'end'无法解析。

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() ?

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);

一个错误将被检测到没有匹配的重载, reset(?)。所以这显然是一个错误。

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天全站免登陆