Welcome to PlantUML Q&A, where you can ask questions and receive answers from other members of the community.

You can also submit new features request and vote for them.

Support for generics/templates

0 votes

I would like to somehow represent templated classes (I am using c++) using plantuml but I am having difficulty doing do.

Is there some workaround so that the below three different classes can be diagrammed in the same diagram 

@startuml
class Foo<T>
class Foo<int>
class Foo<double>
@enduml
 
 
br
John
asked Jun 8 by anonymous

1 Answer

0 votes

Hello,

@startuml
class Foo< T > 
class "Foo<int>" as Foo_int
class "Foo<double>" as Foo_double
@enduml
 
But there is a bug when you try:
@startuml
class Foo< T > as Foo_t
class "Foo<int>" as Foo_int
class "Foo<double>" as Foo_double
Foo_t <|-- Foo_int
Foo_t <|-- Foo_double
@enduml
 

 

answered Jun 9 by Serge Wenger Work (5,150 points)
Thanks for your help. Saved my day. God bless.
Thank you Serge!
We have slightly improved support of generics in last beta:
https://www.dropbox.com/s/koo42q3d9gxw288/plantuml.jar?dl=0
You can now have:

@startuml
class Bar<T>
class "Foo<T>" as Foo_t
class "Foo<int>" as Foo_int
class "Foo<double>" as Foo_double
Foo_t <|-- Foo_int
Foo_t <|-- Foo_double
@enduml

The display is more accurate now.
Tell us if you find other issues!
Regards,
OK. Thanks for the new beta
Support This Project Offer 250 Mo! Follow PlantUML on Twitter
...