0
template<typename T>
struct TBox2
{
}

typedef TBox2<float> FBox2f;

So the template declaration in AST is a CursorKind.CLASS_TEMPLATE. How can I tell the template is a struct or class ?

> tpl.kind
CursorKind.CLASS_TEMPLATE
> tpl.spelling
'TBox2'
> tpl.displayname
'TBox2<T>'
> tpdef.kind
CursorKind.TYPEDEF_DECL
> tpdef.type.spelling
'FBox2f'
> tpdef.underlying_typedef_typetpdef.underlying_typedef_type.spelling
'TBox2<float>'
Joey.Z
  • 4,492
  • 4
  • 38
  • 63
  • `class` and `struct` are not two different things. There is only one thing (a class); declaring a `class` with `struct` changes the default visibility of member declarations. It has no other effect. So it's not retained as part of the type. – rici May 25 '22 at 04:59
  • @rici Right. And this is exactly why I need to tell whether it is a `struct` or `class`. I need to generator some wrapper code for this template based on the ast. And if it is a struct I can safely access all members without concern acout the accessibility. – Joey.Z May 25 '22 at 05:08
  • and some other trivial difference relies on struct when generating – Joey.Z May 25 '22 at 05:19

1 Answers1

0

I firgure it out, you can use Cursor.access_specifier method to get the member is public or private.