refactor: Fix pre-C++11 nested template parsing#2760
Conversation
|
| 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
Reviews (1): Last reviewed commit: "refactor: Fix pre-C++11 nested template ..." | Re-trigger Greptile
| //---------------------------------------------------------------------------- | ||
|
|
||
| typedef std::set<AsciiString, rts::less_than_nocase<AsciiString> > FilenameList; | ||
| typedef std::set<AsciiString, rts::less_than_nocase<AsciiString>/* */> FilenameList; |
There was a problem hiding this comment.
/**/ was not possible with clang format? It did work with VC6.
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:
> >) were updated using this pattern.