-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed as not planned
Closed as not planned
Copy link
Labels
Description
In all versions of C++ supported by ClangFormat, the alternative operator spelling ("digraph") <: is treated as [. However, ClangFormat will remove a space between < and : (except when Standard: c++03 is specified, or Standard: Auto is specified and no double-closing >> is found in the source file):
g< ::T>(); // before
g<::T>(); // after, compiler error
g [ : T > ( ) ; // C++ equivalent tokenizationThis causes problems when:
- the first template parameter must use an absolute namespace (e.g., the code is in
f::g, namespacef::eexists, and the parameter is::e::T), and - the code is not compiled with
-fno-digraphs(or its equivalent in other compilers)
As far as I am aware, this is the only place where the "digraph" alternative spellings can change the meaning of otherwise-valid C++ code (and I believe there is no such case in C, where the digraph operators originated).
There is a (moderately annoying) workaround of adding a dummy comment:
g</**/ ::T>(); // safe