Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Dereference operator for unique_ptr does not work in Eclipse
Dereference operator for unique_ptr does not work in Eclipse [message #890487] Fri, 22 June 2012 12:13 Go to next message
Victor Jimenez is currently offline Victor JimenezFriend
Messages: 2
Registered: June 2012
Junior Member
After following some indications from a post in stackoverflow (basically to add the __GXX_EXPERIMENTAL_CXX0X__ symbol and add the -std=c++0x compiler flag), I managed to make Eclipse (Indigo) recognize unique_ptr (and other C++11 new stuff). The problem is that operator-> for unique_ptr seems not to be supported in Eclipse. Here you have an example:

#include <memory>

class Foo { void bar() { /* ... */ } };

std::unique_ptr<Foo> foo;
(*foo).bar(); // 1
foo->bar();   // 2


Case 1 works as expected: there is no error and autocompletion works. For case 2, however, Eclipse marks the statement with an error ("Method 'bar' could not be resolved"), plus autocompletion from foo-> does not work.

The compilation process goes fine for the code snippet shown above. So, the problem is not in the compiler itself, but on Eclipse.

Most interestingly, I do not have any problems with std::shared_ptr. It only happens for std::unique_ptr.

Has anyone experienced the same problem? Does anyone know a way to fix it?
Re: Dereference operator for unique_ptr does not work in Eclipse [message #890646 is a reply to message #890487] Fri, 22 June 2012 18:48 Go to previous messageGo to next message
Victor Jimenez is currently offline Victor JimenezFriend
Messages: 2
Registered: June 2012
Junior Member
I have downloaded the code for CDT and started to look at the autocompletion part. Can anyone point me where I have to look in order to try to find the problem?

[Updated on: Fri, 22 June 2012 18:48]

Report message to a moderator

Re: Dereference operator for unique_ptr does not work in Eclipse [message #891968 is a reply to message #890646] Tue, 26 June 2012 17:42 Go to previous messageGo to next message
Yevgeny Shifrin is currently offline Yevgeny ShifrinFriend
Messages: 208
Registered: July 2009
Senior Member
Victor Jimenez wrote on Fri, 22 June 2012 14:48
I have downloaded the code for CDT and started to look at the autocompletion part. Can anyone point me where I have to look in order to try to find the problem?



Maybe you should forward this qestion to cdt developers mailing list https://dev.eclipse.org/mailman/listinfo/cdt-dev?

Also I would suggest opening a bug regarding this issue: https://bugs.eclipse.org/bugs/enter_bug.cgi?product=CDT&format=guided
Re: Dereference operator for unique_ptr does not work in Eclipse [message #892061 is a reply to message #890487] Wed, 27 June 2012 03:17 Go to previous message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
On 06/22/2012 07:13 AM, Victor Jimenez wrote:
> After following some indications from a post in stackoverflow (basically
> to add the __GXX_EXPERIMENTAL_CXX0X__ symbol and add the -std=c++0x
> compiler flag), I managed to make Eclipse (Indigo) recognize unique_ptr
> (and other C++11 new stuff). The problem is that operator-> for
> unique_ptr seems not to be supported in Eclipse. Here you have an example:
>
>
> #include <memory>
>
> class Foo { void bar() { /* ... */ } };
>
> std::unique_ptr<Foo> foo;
> (*foo).bar(); // 1
> foo->bar(); // 2
>
>
> Case 1 works as expected: there is no error and autocompletion works.
> For case 2, however, Eclipse marks the statement with an error ("Method
> 'bar' could not be resolved"), plus autocompletion from foo-> does not
> work.
>
> The compilation process goes fine for the code snippet shown above. So,
> the problem is not in the compiler itself, but on Eclipse.
>
> Most interestingly, I do not have any problems with std::shared_ptr. It
> only happens for std::unique_ptr.
>
> Has anyone experienced the same problem? Does anyone know a way to fix it?
Looking closely at this, if you enter:
foo.
and then hit ctrl-space, the auto complete proposals show operator
*(void):Foo and operator ->(void):?.

This would seem to indicate that Eclipse isn't able to identify the
return type of the -> operator for unique_ptr.

Doing the same thing for shared_ptr results in the operations showing
return types of Foo or Foo*.

The template definitions for unique_ptr and shared_ptr specify the
return types differently.

I would also suggest filing a bug report for this specific situation.
Previous Topic:CDT CODAN Indigo Could not resolve common symbols all of a sudden
Next Topic:Console window will not allow navigation to errors
Goto Forum:
  


Current Time: Wed Apr 24 17:16:00 GMT 2024

Powered by FUDForum. Page generated in 0.03027 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top