This commit is contained in:
Günter Obiltschnig
2023-07-11 06:47:40 +02:00
parent 6356cd22ad
commit b0d7f9bd79

View File

@@ -121,25 +121,30 @@ std::string Symbol::extractName(const std::string& decl)
return "operator []"; return "operator []";
std::string::size_type pos = decl.find('('); std::string::size_type pos = decl.find('(');
if (pos != std::string::npos) { if (pos != std::string::npos)
{
// special case std::function<void(int)> a // special case std::function<void(int)> a
// ^ ^^ // ^ ^^
// In case the marked patterns are found, // In case the marked patterns are found,
// reset pos to npos to make sure "(" is not seen as the beginning of a function // reset pos to npos to make sure "(" is not seen as the beginning of a function
int bracket = 1; int bracket = 1;
std::string::size_type i = pos + 1; std::string::size_type i = pos + 1;
while (i < decl.size() && bracket != 0){ while (i < decl.size() && bracket != 0)
if (decl[i] == '('){ {
if (decl[i] == '(')
{
bracket++; bracket++;
} else if (decl[i] == ')'){ }
else if (decl[i] == ')')
{
bracket--; bracket--;
} }
i++; i++;
} }
while (i < decl.size() && std::isspace(decl[i])) i++; while (i < decl.size() && std::isspace(decl[i])) i++;
if (i < decl.size() && decl[i] == '>') { if (i < decl.size() && decl[i] == '>')
{
pos = std::string::npos; pos = std::string::npos;
} }
} }