def add_target_and_index(self, ast: ASTDeclaration, sig: str, signode: TextElement) -> None:
    ids = []
    for i in range(1, (_max_id + 1)):
        try:
            id = ast.get_id(version=i)
            ids.append(id)
        except NoOldIdError:
            assert (i < _max_id)
    ids = list(reversed(ids))
    newestId = ids[0]
    assert newestId
    if (not re.compile('^[a-zA-Z0-9_]*$').match(newestId)):
        logger.warning('Index id generation for C++ object "%s" failed, please report as bug (id=%s).', ast, newestId, location=self.get_source_info())
    name = ast.symbol.get_full_nested_name().get_display_string().lstrip(':')
    isInConcept = False
    s = ast.symbol.parent
    while (s is not None):
        decl = s.declaration
        s = s.parent
        if (decl is None):
            continue
        if (decl.objectType == 'concept'):
            isInConcept = True
            break
    if (not isInConcept):
        strippedName = name
        for prefix in self.env.config.cpp_index_common_prefix:
            if name.startswith(prefix):
                strippedName = strippedName[len(prefix):]
                break
        indexText = self.get_index_text(strippedName)
        self.indexnode['entries'].append(('single', indexText, newestId, '', None))
    if (newestId not in self.state.document.ids):
        names = self.env.domaindata['cpp']['names']
        if (name not in names):
            names[name] = ast.symbol.docname
        assert newestId
        signode['ids'].append(newestId)
        for id in ids[1:]:
            if (not id):
                continue
            if (id not in self.state.document.ids):
                signode['ids'].append(id)
        self.state.document.note_explicit_target(signode)
def add_target_and_index(self, ast: ASTDeclaration, sig: str, signode: TextElement) -> None:
    ids = []
    for i in range(1, (_max_id + 1)):
        try:
            id = ast.get_id(version=i)
            ids.append(id)
        except NoOldIdError:
            assert (i < _max_id)
    ids = list(reversed(ids))
    newestId = ids[0]
    assert newestId
    if (not re.compile('^[a-zA-Z0-9_]*$').match(newestId)):
        logger.warning('Index id generation for C++ object "%s" failed, please report as bug (id=%s).', ast, newestId, location=self.get_source_info())
    name = ast.symbol.get_full_nested_name().get_display_string().lstrip(':')
    isInConcept = False
    s = ast.symbol.parent
    while (s is not None):
        decl = s.declaration
        s = s.parent
        if (decl is None):
            continue
        if (decl.objectType == 'concept'):
            isInConcept = True
            break
    if (not isInConcept):
        strippedName = name
        for prefix in self.env.config.cpp_index_common_prefix:
            if name.startswith(prefix):
                strippedName = strippedName[len(prefix):]
                break
        indexText = self.get_index_text(strippedName)
        self.indexnode['entries'].append(('single', indexText, newestId, , None))
    if (newestId not in self.state.document.ids):
        names = self.env.domaindata['cpp']['names']
        if (name not in names):
            names[name] = ast.symbol.docname
        assert newestId
        signode['ids'].append(newestId)
        for id in ids[1:]:
            if (not id):
                continue
            if (id not in self.state.document.ids):
                signode['ids'].append(id)
        self.state.document.note_explicit_target(signode)