Skip to content

Commit

Permalink
support SFINAE for classes
Browse files Browse the repository at this point in the history
#feat
alandefreitas committed Jan 22, 2025
1 parent fd90016 commit 5de708b
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/lib/AST/ASTVisitor.cpp
Original file line number Diff line number Diff line change
@@ -1193,6 +1193,34 @@ populate(
populate(Template.Args, CTSD->getTemplateArgs().asArray());
}

// Extract requires clause from SFINAE context
for (auto it = Template.Args.begin(); it != Template.Args.end();)
{
auto& arg = *it;
if (!arg)
{
++it;
continue;
}
if (auto* T = dynamic_cast<TypeTArg*>(arg.get());
T &&
T->Type &&
!T->Type->Constraints.empty())
{
for (ExprInfo const& constraint: T->Type->Constraints)
{
if (!Template.Requires.Written.empty())
{
Template.Requires.Written += " && ";
}
Template.Requires.Written += constraint.Written;
}
it = Template.Args.erase(it);
continue;
}
++it;
}

// Extract the template parameters if this is a partial specialization
if (auto* CTPSD = dyn_cast<ClassTemplatePartialSpecializationDecl>(CTSD))
{

0 comments on commit 5de708b

Please sign in to comment.