2

I found this weird code on the net but can't figure out what it does. When I compile it I don't get any output.

int main()<%auto f = <::><%%>;%>

2 Answers2

12

Using digraphs, <% corresponds to {, and %> corresponds to }.

Substituting these in yields

int main(){ auto f = <::>{}; }

Finally, <: is equivalent to [ and :> to ], so we end up with

int main(){ auto f = []{}; }

where []{} is an empty lambda, and f is a copy of the closure object.

Columbo
  • 58,324
  • 8
  • 149
  • 196
6

It uses digraphs to obfuscate some simple code. It is exactly the same as

int main() { auto f = []{}; }

In other words, not much. It just instantiates an empty lambda, binding it to f. f isn't even called.

juanchopanza
  • 216,937
  • 30
  • 383
  • 461