Files
clang-uml/docs/test_cases/t20018.md
2022-12-09 23:49:34 +01:00

45 lines
938 B
Markdown

# t20018 - Recursive template sequence diagram test case
## Config
```yaml
compilation_database_dir: ..
output_directory: puml
diagrams:
t20018_sequence:
type: sequence
glob:
- ../../tests/t20018/t20018.cc
include:
namespaces:
- clanguml::t20018
using_namespace:
- clanguml::t20018
start_from:
- function: "clanguml::t20018::tmain()"
```
## Source code
File t20018.cc
```cpp
#include <iostream>
namespace clanguml {
namespace t20018 {
template <int N> struct Factorial {
static const int value = N * Factorial<N - 1>::value;
static void print() { Factorial<N - 1>::print(); }
};
template <> struct Factorial<0> {
static const int value = 1;
static void print() { std::cout << "Hello world\n"; }
};
void tmain() { Factorial<5>::print(); }
}
}
```
## Generated UML diagrams
![t20018_sequence](./t20018_sequence.svg "Recursive template sequence diagram test case")