Updated test case documentation
This commit is contained in:
58
docs/test_cases/t20019.md
Normal file
58
docs/test_cases/t20019.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# t20019 - Curiously Recurring Template Pattern sequence diagram test case
|
||||
## Config
|
||||
```yaml
|
||||
compilation_database_dir: ..
|
||||
output_directory: puml
|
||||
diagrams:
|
||||
t20019_sequence:
|
||||
type: sequence
|
||||
glob:
|
||||
- ../../tests/t20019/t20019.cc
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml::t20019
|
||||
using_namespace:
|
||||
- clanguml::t20019
|
||||
start_from:
|
||||
- function: "clanguml::t20019::tmain()"
|
||||
```
|
||||
## Source code
|
||||
File t20019.cc
|
||||
```cpp
|
||||
#include <cstdio>
|
||||
|
||||
namespace clanguml {
|
||||
namespace t20019 {
|
||||
|
||||
// From https://en.cppreference.com/w/cpp/language/crtp
|
||||
|
||||
template <class Derived> struct Base {
|
||||
void name() { (static_cast<Derived *>(this))->impl(); }
|
||||
};
|
||||
|
||||
struct D1 : public Base<D1> {
|
||||
void impl() { std::puts("D1::impl()"); }
|
||||
};
|
||||
|
||||
struct D2 : public Base<D2> {
|
||||
void impl() { std::puts("D2::impl()"); }
|
||||
};
|
||||
|
||||
void tmain()
|
||||
{
|
||||
Base<D1> b1;
|
||||
b1.name();
|
||||
Base<D2> b2;
|
||||
b2.name();
|
||||
|
||||
D1 d1;
|
||||
d1.name();
|
||||
D2 d2;
|
||||
d2.name();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
## Generated UML diagrams
|
||||

|
||||
Reference in New Issue
Block a user