← Back to archive

Stdle #166 · modern · 2026-11-19

What does this C++ snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

#include <iostream>
int main() {
auto twice = [](auto f, int x) { return f(f(x)); };
auto inc = [](int x) { return x + 1; };
std::cout << twice(inc, 5) << "\n";
}
Modern
4 attempts left

Answer & explanation