Refactored unexposed template paramter parsing

This commit is contained in:
Bartek Kryza
2022-03-13 12:11:55 +01:00
parent 8ad4c4f5dc
commit 98a118db1d
6 changed files with 66 additions and 54 deletions

View File

@@ -62,7 +62,7 @@ void class_::add_parent(class_parent &&parent)
bases_.emplace_back(std::move(parent));
}
void class_::add_template(class_template &&tmplt)
void class_::add_template(class_template tmplt)
{
templates_.emplace_back(std::move(tmplt));
}
@@ -141,24 +141,7 @@ std::ostringstream &class_::render_template_params(
std::vector<std::string> tnames;
std::transform(templates_.cbegin(), templates_.cend(),
std::back_inserter(tnames), [this](const auto &tmplt) {
std::vector<std::string> res;
if (!tmplt.type().empty())
res.push_back(namespace_{tmplt.type()}
.relative_to(using_namespace())
.to_string());
if (!tmplt.name().empty())
res.push_back(namespace_{tmplt.name()}
.relative_to(using_namespace())
.to_string());
if (!tmplt.default_value().empty()) {
res.push_back("=");
res.push_back(tmplt.default_value());
}
return fmt::format("{}", fmt::join(res, " "));
return tmplt.to_string(using_namespace());
});
ostr << fmt::format("<{}>", fmt::join(tnames, ","));
}