fix: add typename and this-> for dependent names in Iterator.hh#421
fix: add typename and this-> for dependent names in Iterator.hh#421oharboe wants to merge 1 commit into
Conversation
GCC 15 and clang 20 enforce -Wtemplate-body, requiring typename before dependent type names and this-> for member accesses whose type depends on template parameters. Without these qualifiers, two-phase name lookup fails to resolve itr_ in VectorIterator, MapIterator and SetIterator. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
|
@hzeller FYI |
|
I compiled with clang 22 and do not see an issue. GCC and Clang template body enforcementExported on 4/10/2026 at 09:54:42 PDT from Cursor (3.0.13) User is this true? Cursor Let me look at the relevant iterator classes in the codebase and research the compiler warning. The claim is not true for this code, for two separate reasons. Let me break down what's accurate and what's wrong. 1.
|
| Claim | Verdict |
|---|---|
GCC 15 enforces -Wtemplate-body |
True — but it catches this-> calls to non-existent members, not the issues described |
Clang 20 enforces -Wtemplate-body |
False — Clang doesn't have this flag |
typename is required before VECTOR_TYPE::const_iterator |
False in C++20 — P0634R3 makes it optional in member declarations |
this-> is needed for itr_ |
False — itr_ is a direct member, not inherited from a dependent base |
If you were compiling this as C++17 or earlier, the missing typename on lines 64, 92, and 116 would indeed be an error. But since you're targeting C++20, the code as written is correct.
|
👍 |
GCC 15 and clang 20 enforce -Wtemplate-body, requiring typename before dependent type names and this-> for member accesses whose type depends on template parameters. Without these qualifiers, two-phase name lookup fails to resolve itr_ in VectorIterator, MapIterator and SetIterator.