I am creating a class diagram in visual paradigm. I have a typedef :
typedef std::vector<A> Va;
and I want to represent this on visual paradigm by showing the type std::vector<A> in the representation but I don't see how
I am creating a class diagram in visual paradigm. I have a typedef :
typedef std::vector<A> Va;
and I want to represent this on visual paradigm by showing the type std::vector<A> in the representation but I don't see how
Copyright © 2021 Jogjafile Inc.

Is one stereotype enough?
Visual Paradigm offers a
<<Typedef>>stereotype out of the box that can be used as shown in your diagram. It looks like a<<primitive>>type. Unfortunately, it fails to acknowledge that atypedefis only an alias. So how could the model tell anything about attributes or operations of atypedef?How to show the alias in UML?
The closest way is to use specialization (inheritance). If
vAwould be an UML specialization ofvector<A>, it would have the same (public) attributes and operations.But the specialization does not fully reflect the true nature of a
typedef: a typedef does not define a new distinct type; it only defines a new alternative name for an existing type. You can use any of the aliases interchangeably:A very pragmatic and effective way to document this kind of relationship in UML, is to define a stereotype
«typedef»stereotype for the specialization, being understood that the C++ semantic would apply:(The templated vector is not required, you could start at
vector<A>if you'd wished)How to define the specialization stereotype in Visual Paradigm?
First, draw the generalization shape (inheritance).
Right click on the new generalization that you've created from
vector<A>tovA, and choseStereotypes > Edit Stereotypes...in the contextual menu.Then in the popup window, click on the button
Edit Stereotypes.... In the new popup window, click onAdd...button, and in the new popup type intypedefas stereotype. Click on ok, and the new stereotype is created, click on ok and it's added to the list of available stereotypes:Up from now, you can easily select the home-made stereotype to generalizations. You could even decide to selectively show and hide the stereotyped specializations in the diagram, while having all the information in the model (see comments for details).
Shorter way?
If you don't need in your model the operations and attributes of vA, but just want a compact hint about the real type, you could make use of tagged values. These can be associated to stereotypes.
You can for example enrich the built-in
<<Typedef>>stereotype for classes, by adding a tagged value namedAlias forthat takes as value aModel element:From then onward, for every class that has the
<<Typedef>>stereotype you can open its specification and enrich the tab "Tagged values", selecting other elements in your model (not necessarily in the same diagram).To visualize tagged values, you first need to activate them in the diagram, via the contextual menu (Presentation options > Show tagged values > Show non-empty). You'd then have something like:
Not related:
You may want to consider using:
If you think that it's just a matter of stylistic preference, I'd warmheartedly recommend you Scott Meyer's book "Effective Modern C++" and in particular the dedicated section "Item 9: prefer alias declaration to typedefs".