|
|
|
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 |
David Wegener 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.
|
|
|
Powered by
FUDForum. Page generated in 0.03027 seconds