UML中的模板方法

UML中的模板方法

问题描述:

有什么方法可以显示UML中的模板方法(我的意思是c ++模板方法,而不是模式)?我只找到模板类.

Is there any way to display template method in UML (I mean a c++ template method, not pattern)? I've found template classes only.

假设我有

class A {
  public:
    template <typename T>
    std::vector<T> func(T& var);
};

因此,我现在可以在uml中显示它的唯一方法是+func(in var : T&) : std::vector<T>.有没有办法说它是模板,而T不是通常的类型?

So, the only way I can display it in uml now is +func(in var : T&) : std::vector<T>. Is there any way to say it's template, and T is not a usual type?

我在这里不确定,但我认为答案是否定的.

I'm not entirely sure here, but I think the answer is no.

如果我理解正确,UML只能处理类级别的模板-这意味着需要将您的类A指定为模板类,才能使func()有效.

If I understand it correctly, UML can only deal with templates on a class level -- meaning that your class A would need to be specified as a template class in order for func() to be valid.

换一种说法,UML不允许在没有在类签名中指定模板参数的情况下将模板参数引入操作中.我想.

Put another way, UML does not allow template parameters to be introduced in an operation without also being specified in the class signature. I think.

请始终记住,UML不是一种编程语言,实际上,当遇到任何特定语言的非平凡的源代码结构时,UML往往会崩溃.

Bear in mind always that UML is not a programming language and in fact tends to break down when confronted with non-trivial source code constructs in any particular language.

更多信息此处.