Fixed template instantiation with mixed type and non-type parameters

This commit is contained in:
Bartek Kryza
2021-03-14 11:59:50 +01:00
parent 0fc862332a
commit 93310b54e0
4 changed files with 44 additions and 50 deletions

View File

@@ -1,4 +1,5 @@
#include <algorithm>
#include <map>
#include <numeric>
#include <variant>
@@ -14,12 +15,20 @@ template <int... Is> class B {
std::array<int, sizeof...(Is)> ints;
};
template <typename T, int... Is> class C {
std::array<T, sizeof...(Is)> ints;
};
class R {
A<int, std::string, float> a1;
A<int, std::string, bool> a2;
B<3, 2, 1> b1;
B<1, 1, 1, 1> b2;
C<std::map<int, std::vector<std::vector<std::vector<std::string>>>>, 3, 3,
3>
c1;
};
}
}

View File

@@ -47,6 +47,15 @@ TEST_CASE("Test t00012", "[unit-test]")
REQUIRE_THAT(puml, IsClassTemplate("A", "T, Ts..."));
REQUIRE_THAT(puml, IsClassTemplate("B", "int Is..."));
REQUIRE_THAT(puml, IsInstantiation(_A("B<int Is...>"), _A("B<3, 2, 1>")));
REQUIRE_THAT(
puml, IsInstantiation(_A("B<int Is...>"), _A("B<1, 1, 1, 1>")));
REQUIRE_THAT(puml,
IsInstantiation(_A("C<T, int Is...>"),
_A("C<std::map<int, "
"std::vector<std::vector<std::vector<std::string>>>>, 3, 3, "
"3>")));
save_puml(
"./" + config.output_directory + "/" + diagram->name + ".puml", puml);
}