Skip to content

refactor: Fix pre-C++11 nested template parsing#2760

Open
DevGeniusCode wants to merge 1 commit into
TheSuperHackers:mainfrom
DevGeniusCode:clang/fix-typedef-extractor
Open

refactor: Fix pre-C++11 nested template parsing#2760
DevGeniusCode wants to merge 1 commit into
TheSuperHackers:mainfrom
DevGeniusCode:clang/fix-typedef-extractor

Conversation

@DevGeniusCode
Copy link
Copy Markdown

This PR resolves compilation errors in pre-C++11 compilers (such as VC6) caused by the >> token sequence in nested template declarations.

Instead of restructuring the code with typedefs, the issue is addressed by safely separating the consecutive closing angle brackets with an empty comment: >/* */>. This prevents the compiler from misinterpreting the sequence as a right-shift operator while preserving the original code structure and type definitions intact.

Key Details:

  • Scope: A total of 68 instances of nested templates (found by searching for > >) were updated using this pattern.
  • Edge Cases & Comments: Nested templates located within code comments were intentionally left unchanged.

@DevGeniusCode DevGeniusCode added the Refactor Edits the code with insignificant behavior changes, is never user facing label May 30, 2026
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 30, 2026

Greptile Summary

This PR applies a targeted pre-C++11 compatibility fix across 48 files, replacing the > > spacing pattern in nested template closing brackets with >/* */>. The empty comment prevents old compilers like VC6 from tokenizing the two consecutive > characters as a single >> (right-shift) operator.

  • ~68 typedef/declaration sites across headers and source files in Core/, Generals/, and GeneralsMD/ are updated with the >/* */> trick; instances inside code comments are intentionally left unchanged.
  • The change is purely syntactic and has no semantic effect on any modern compiler (C++11 and later already handle >> correctly in template contexts), making this fully backward-compatible.

Confidence Score: 5/5

Safe to merge — all changes are purely syntactic comment insertions with no runtime behavior change.

The PR is a mechanical search-and-replace across 48 files: the only modification is inserting an empty /* */ comment between two consecutive > characters in nested template declarations. The /* */ token is stripped by the preprocessor and has zero semantic effect on any compiler. Modern compilers (C++11+) see identical code after preprocessing, and older compilers (VC6) now correctly tokenize the two angle brackets as separate tokens. No logic, data structures, or function signatures are altered.

No files require special attention. The most structurally complex changes are in AudioEvents.h (base class + four using declarations) and STLUtils.h (return types and constructor calls in function templates), both of which are correctly handled.

Important Files Changed

Filename Overview
Core/Libraries/Source/WWVegas/WWAudio/AudioEvents.h Fix applied to base class declaration and four using declarations inside AudioCallbackListClass template; all AUDIO_CALLBACK_STRUCT<T>/* */> substitutions are correct.
Core/Libraries/Source/WWVegas/WWLib/STLUtils.h Fix applied to return types and constructor calls in get_range template functions; placement of /* */ between inner and outer > is correct in all four occurrences.
Core/GameEngine/Include/Common/FileSystem.h Two typedef declarations (FilenameList, FileExistMap) corrected; multiline hash_map typedef correctly has the comment on the final template argument line.
Core/GameEngine/Source/Common/Audio/GameAudio.cpp Two std::list<std::pair<...>>::iterator declarations patched; changes are consistent with the header-level typedef in GameAudio.h.
Generals/Code/GameEngine/Include/GameLogic/GameLogic.h Two private hash_map typedefs (BuildableMap, ControlBarOverrideMap) updated; mirrored identically in GeneralsMD.
Core/Tools/matchbot/wlib/ustring.h Fix applied to base class declaration and two pointer declarations inside operator==; all three uses of basic_string<charT, string_char_traits<charT>/* */> are syntactically correct.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["Pre-C++11 compiler tokenizer\n(e.g. VC6)"] --> B{Sees consecutive\nangle brackets}
    B -->|"SomeType<T> >"| C["Tokenized as\n'>' + '>'  ✓"]
    B -->|"SomeType<T>>"| D["Tokenized as\n'>>' right-shift ✗"]
    C --> E["Template closes correctly"]
    D --> F["Compilation error"]
    G["PR Fix: insert comment"] --> H["SomeType<T>/* */>"]
    H --> I["Preprocessor strips comment\n→ 'T>' + '>'"]
    I --> C
    style D fill:#ff6b6b,color:#fff
    style F fill:#ff6b6b,color:#fff
    style E fill:#51cf66,color:#fff
    style G fill:#339af0,color:#fff
Loading

Reviews (1): Last reviewed commit: "refactor: Fix pre-C++11 nested template ..." | Re-trigger Greptile

Copy link
Copy Markdown

@xezon xezon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silly we need to do that 🥲

//----------------------------------------------------------------------------

typedef std::set<AsciiString, rts::less_than_nocase<AsciiString> > FilenameList;
typedef std::set<AsciiString, rts::less_than_nocase<AsciiString>/* */> FilenameList;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/**/ was not possible with clang format? It did work with VC6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor Edits the code with insignificant behavior changes, is never user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants