Fixed template template example

This commit is contained in:
Bartek Kryza
2021-03-30 00:39:23 +02:00
parent 928e5f5baa
commit d25a252212
3 changed files with 11 additions and 8 deletions

View File

@@ -306,7 +306,10 @@ void tu_visitor::process_field(const cppast::cpp_member_variable &mv, class_ &c,
spdlog::debug( spdlog::debug(
"Processing field with unreferenced type of kind {}", tr.kind()); "Processing field with unreferenced type of kind {}", tr.kind());
if (tr.kind() == cppast::cpp_type_kind::template_instantiation_t) { if (tr.kind() == cppast::cpp_type_kind::builtin_t) {
spdlog::debug("Builtin type found for field: {}", m.name);
}
else if (tr.kind() == cppast::cpp_type_kind::template_instantiation_t) {
spdlog::debug("Processing field with template instatiation type {}", spdlog::debug("Processing field with template instatiation type {}",
cppast::to_string(tr)); cppast::to_string(tr));

View File

@@ -17,19 +17,18 @@ public:
CMP comparator; CMP comparator;
}; };
/* template <typename T> struct Vector {
* TODO: Handle template template properly. std::vector<T> values;
* };
template <typename T, template <typename> typename C> struct B { template <typename T, template <typename> typename C> struct B {
C<T> template_template; C<T> template_template;
}; };
struct D { struct D {
// libclang claims that the type spelling of 'ints' is 'int'... B<int, Vector> ints;
B<int, std::vector> ints;
void add(int i) { ints.template_template.push_back(i); } void add(int i) { ints.template_template.values.push_back(i); }
}; };
*/
} }
} }

View File

@@ -43,6 +43,7 @@ TEST_CASE("t00008", "[test-case][class]")
REQUIRE_THAT(puml, StartsWith("@startuml")); REQUIRE_THAT(puml, StartsWith("@startuml"));
REQUIRE_THAT(puml, EndsWith("@enduml\n")); REQUIRE_THAT(puml, EndsWith("@enduml\n"));
REQUIRE_THAT(puml, IsClassTemplate("A", "T, P, bool (*)(int, int), int N")); REQUIRE_THAT(puml, IsClassTemplate("A", "T, P, bool (*)(int, int), int N"));
REQUIRE_THAT(puml, IsClassTemplate("B", "T, C<>"));
REQUIRE_THAT(puml, IsField(Public("T value"))); REQUIRE_THAT(puml, IsField(Public("T value")));
REQUIRE_THAT(puml, IsField(Public("T * pointer"))); REQUIRE_THAT(puml, IsField(Public("T * pointer")));