Support for generics/templates

0 votes
asked Jun 8, 2017 in Closed question / help 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

Even better, I dunno if these types of diagrams are possible https://stackoverflow.com/questions/15330957/visual-studio-uml-class-diagram-modeling-of-generic-types/15350759#15350759

br

John

1 Answer

0 votes
answered Jun 9, 2017 by Serge Wenger Work (9,670 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, 2017 by anonymous
Thanks for your help. Saved my day. God bless.
commented Jun 10, 2017 by plantuml (179,660 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, 2017 by Serge Wenger Work (9,670 points)
OK. Thanks for the new beta
...