Files
clang-uml/docs/test_cases/t20008.md
2022-11-27 15:26:21 +01:00

68 lines
1.2 KiB
Markdown

# t20008 - Constexpr if sequence diagram test case
## Config
```yaml
compilation_database_dir: ..
output_directory: puml
diagrams:
t20008_sequence:
type: sequence
glob:
- ../../tests/t20008/t20008.cc
include:
namespaces:
- clanguml::t20008
using_namespace:
- clanguml::t20008
start_from:
- function: "clanguml::t20008::tmain()"
```
## Source code
File t20008.cc
```cpp
#include <string>
#include <type_traits>
namespace clanguml {
namespace t20008 {
template <typename T> struct A {
void a1(T arg) { }
void a2(T arg) { }
void a3(T arg) { }
};
template <typename T> struct B {
A<T> a;
void b(T arg)
{
if constexpr (std::is_integral_v<T>) {
a.a1(arg);
}
else if constexpr (std::is_pointer_v<T>) {
a.a2(arg);
}
else {
a.a3(arg);
}
}
};
void tmain()
{
using namespace std::string_literals;
B<int> bint;
B<const char *> bcharp;
B<std::string> bstring;
bint.b(1);
bcharp.b("1");
bstring.b("1"s);
}
}
}
```
## Generated UML diagrams
![t20008_sequence](./t20008_sequence.svg "Constexpr if sequence diagram test case")