GCC doesn't compile this code, while other compilers (clang, msvc) do
template<auto T>
struct S { };
int main() {
S<[]{int x,y; x<<y;}> s1; // compiles fine
S<[]{int x,y; x>>y;}> s2; // error
}
error:
error: expected ';' before '>>' token
| S<[]{int x,y; x>>y;}> s2;
| ^~
| ;
However when I explicitly call operator>>
, GCC accepts it
struct S2 {
void operator>>(S2 arg) { }
};
S<[]{S2 x,y; x.operator>>(y);}> s2; // compiles
It also does compile when I move the lambda definition outside of template parameter list
auto lam = []{int x,y; x>>y;};
S<lam> s; // compiles
Is it a compiler bug?