This syntax is recognized by nvcc to assign numbers of threads and blocks in CUDA kernel calls, but is there any context in which it is legal C++, outside of CUDA? (Any C++ version, including drafts?)
As another way of phrasing this question, is the appearance of <<<
outside of quotes in source code a reliable indicator that it must be CUDA (or syntactically incorrect)?
(I know that >>>
can happen when closing a triply-nested template argument, but the opening brackets would need identifiers between them.)
<<<
or >>>
are not operators (see cppreference for a list), however, you may run into >>>
in a template context:
T<U<V<>>>
See also [gram.lex] for a complete summary of the lexical elements of C++ (which includes operators, keywords, and everything else).
<<<
is also not a perfect indicator, although it is much less common:
template <typename T = /* ... */>
/* ... */ U::operator<<(/* ... */) { /* ... */ }
// taking the address of the overloaded left-shift operator template
&U::operator<<<>
Such cases were uncommon enough to not be of major concern when the introduction of C++20's <=>
operator broke T<&U::operator<=>
.
You're unlikely to ever find it in real code.