How can we express Concept in UML diagram?

限于喜欢 提交于 2019-12-06 15:28:31
xmojmr

After reading shortly Wikipedia explanation of C++ "concepts" it looks to me like tool with same goals as generic classes and type constraints in C#

If I understood it correctly then by following older Stack Overflow question Representing a C# Generic Method in a UML Class Diagram it turns out that you should check the http://www.uml-diagrams.org/template.html as already suggested by @Aleks

Basically I mean to model your interfaces and classes as you'd normally do it. Just use the templating annotation and you can also chart some type restrictions using a virtual dependency, inheritance associations between the formal parameters used in the template

Basically the question can be answered with an answer to the "base class" question : "does UML make any attempt to make it 1-to-1 fitting to C++?"

Answer is simply "no".

This is a very common misunderstanding, one can meet people looking for possibilities of expressing a pointer in UML or any other C++ specific things. You will unluckily not find it.

The misunderstanding is comes historically from the availability of C++ code generation engines which come with some UML modeling tools. All those code generation engines come with their own coding patterns to address the transition from model to code. Simply because there is no standard for the transition patterns itself.

UML comes from OMG and OMG has a generation patterns document for (Corba)IDL-to-C++ but none for UML-to-C++.

You can show in UML all structures used by concept - i.e., functions, algorithms, classes and so on. But not the concept itself, for it is an element creating syntax.

Also, you can't show in UML macros, preprocessor commands, etc.

All these things simply do not belong to model, but to the language/grammar/syntax. There are other tools for their support. Formal grammars, theories, etc. Yes, there are diagrams for it. Look for "formal grammar diagrams" in google and you'll see heaps of them.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!