According to the C++23 standard, what is the output of this program?
#include <iostream>
struct S {
template <typename Callable>
void operator[](Callable f) {
f();
}
};
int main() {
auto caller = S{};
caller[ []{ std::cout << "C";} ];
}What does two [[consecutive]] square brackets usually mean? Could there be a parsing problem here?
The program has a compilation error
Two consecutive square brackets are normally used for [[attributes]], and indeed we are not allowed to use them like this here. §[dcl.attr.grammar]¶7 in the standard says:
Two consecutive left square bracket tokens shall appear only when introducing an attribute-specifier or within the balanced-token-seq of an attribute-argument-clause.
and even gives a similar example.