Support for generics/templates

0 votes
asked Jun 8 by anonymous

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

1 Answer

0 votes
answered Jun 9 by Serge Wenger Work (5,360 points)

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
 

 

commented Jun 9 by anonymous
Thanks for your help. Saved my day. God bless.
commented Jun 10 by plantuml (134,510 points)
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,
commented Jun 12 by Serge Wenger Work (5,360 points)
OK. Thanks for the new beta
...