[aspectc-user] Another puma question.

Matthias Urban matthias.urban at pure-systems.com
Mon Nov 13 10:34:17 CET 2006


Hi Robert,

> Just a quick one this time.
> 
> As I descend into the depths of templates, I can't seem to differentiate 
> between specialisations in the class database. i.e. if I have two classes, 
> fooclass<char * , double> and fooclass<String , unsigned>, they both turn up 
> in the class database as classes named fooclass and having almost all the 
> same attributes.
> 
> Short of looking at their sourceinfo, how can I differentiate between these? 
> What methods should I be looking at to tell me what their specialisation 
> parameters are? I'm just working with some doxygen docs here.

You have to get the instantiation info for a template instance. With 
this info you have access to the template that was instantiated, to the 
template arguments given at the declaration of the instance, and to the 
deduced arguments used for the instantiation itself (different for 
template specializations). E.g.

   template<class T,int I>
   class X {...};

   // instantiation args: int, 1
   // deduced args      : int, 1
   X<int,1> x1;

   template<class T>
   class X<T,2> {...};

   // instantiation args: int
   // deduced args      : int, 2
   X<int> x2;

Here a little code example:

   // any semantic object (class or whatever)
   CObjectInfo* info = ...;
   // is a template instance?
   if (info->isTemplateInstance()) {
     // get instantiation infos
     CTemplateInstance* inst = info->TemplateInstance();
     // access 1st template instantiation argument
     inst->InstantiationArg(0);
     // access 1st deduced template argument
     inst->DeducedArg(0);
   }

Best regards,
Matthias

-- 
Matthias Urban                          Phone: +49-391-544569-32
pure-systems GmbH                       Fax:   +49-391-544569-90



More information about the aspectc-user mailing list