diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py index a6d0a2abe..e8990b235 100644 --- a/sphinx/domains/cpp.py +++ b/sphinx/domains/cpp.py @@ -915,8 +915,6 @@ class ASTNestedName(ASTBase): assert len(names) > 0 self.names = names self.rooted = rooted - for i in range(len(names) - 1): - assert not names[i].is_operator() @property def name(self): @@ -2123,17 +2121,13 @@ class Symbol(object): s = s.parent symbols.reverse() key = [] - for s in symbols[:-1]: - assert s.identifier - nne = ASTNestedNameElement(s.identifier, s.templateArgs) + for s in symbols: + if s.identifier: + nne = ASTNestedNameElement(s.identifier, s.templateArgs) + else: + assert s.declaration + nne = s.declaration.name.names[-1] key.append((nne, s.templateParams)) - s = symbols[-1] - if s.identifier: - nne = ASTNestedNameElement(s.identifier, s.templateArgs) - else: - assert self.declaration - nne = s.declaration.name.names[-1] - key.append((nne, s.templateParams)) return key def get_full_nested_name(self): diff --git a/tests/test_domain_cpp.py b/tests/test_domain_cpp.py index 9d6b6c3e2..e0d5a3086 100644 --- a/tests/test_domain_cpp.py +++ b/tests/test_domain_cpp.py @@ -304,6 +304,15 @@ def test_templates(): "void allow(F *f, typename func::type tt)", None, "I0E5allowP1FN4funcI1F1BXG!=1EE4typeE") + # from #2058 + check('function', + "template " + "inline std::basic_ostream &operator<<(" + "std::basic_ostream &os, " + "const c_string_view_base &str)", + None, "I00ElsRNSt13basic_ostreamI4Char6TraitsEE" + "RK18c_string_view_baseIK4Char6TraitsE") + def test_class(): check('class', 'A final', 'A', '1A')