Hello Eric,

thanks for your answer. I imagine that handling C++ template expansion must be a tricky stuff! I am interested if there are enhancements on the subject.

I have continued my tests on semantic completion for smart pointers. The completion works with boost shared_ptr but not with STL shared_ptr. Here are two code samples explaining why completion does not work in STL case.

------------------------------------------------------------------------------------------------------------

//sample 1 based on STL smart pointer implementation: std::tr1::shared_ptr
class Foo
{
public:
  int foo_attribute;
};

template<typename T>
class __SmartPtr
{
public:
  T* operator->() const {}
};

template<typename T>
class SmartPtr : public __SmartPtr<T>
{};

int main()
{
  __SmartPtr<Foo> p1;
  p1->//completion works and displays "foo_attribute"
  SmartPtr<Foo> p2;
  p2->//completion does not work
}

------------------------------------------------------------------------------------------------------------

//sample 2 based on Boost TR1 smart pointer implementation: std::tr1::shared_ptr
class Foo
{
public:
  int foo_attribute;
};

namespace NS1
{
  template<typename T>
  class SmartPtr
  {
  public:
    T* operator->() const {}
  };
}

namespace NS2
{
  using NS1::SmartPtr;
}

int main()
{
  NS1::SmartPtr<Foo> p1;
  p1->//completion works and displays "foo_attribute"
  NS2::SmartPtr<Foo> p2;
  p2->//completion does not work
}

------------------------------------------------------------------------------------------------------------

I hope these samples will be useful to enhance semantic. Thanks again for your help.

François

On Thu, Aug 29, 2013 at 4:04 AM, Eric M. Ludlam <eric@siege-engine.com> wrote:
Hi Francois,

I believe David Engster has some pending enhancements to how templates are expanded in C++ situations, but I don't know if it covers this case.  I'll let him answer this specific question.

In general, the template expansion is unique to the C++ support code in Semantic.  It works by trying to do the expansion in-place as you ask for completions. Unfortunately, semantic doesn't yet handle everything that C++ can do.

Eric


On 08/23/2013 03:03 PM, francois barjon wrote:
Hello,

I'm currently testing the emacs 24.3 embedded version of semantic. Thanks for this great
and impressive tool!

By trying to use completion for STL smart pointers, I have faced a problem with nested typedef and template.

Here is an example.

-------------------------------

class Bar
{
public:
   int bar_attribute;

};

template<typename T>
class TFoo1
{
public:
   T* operator->() {}
};

template<typename T>
class TFoo2
{
public:
   typedef T NestedT;
   NestedT* operator->() {}

};

int main()
{
   TFoo1<Bar>  o1;
   o1->// completion works and displays"bar_attribute"
   TFoo2<Bar>  o2;
   o2->// completion doesn't work
}

-------------------------------


When the completion doesn't work (using semantic-analyze-possible-completions), semantic displays the following message: Cannot find types for `TFoo2 o2'.

Thanks in advance for your help,

François



------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk



_______________________________________________
cedet-semantic mailing list
cedet-semantic@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cedet-semantic