How Many C++ Keywords Can Be Used in Succession?

Once I was listening to a boring lecture about sorting algorithms. The lecture was boring not only for me but also for all my neighbors. We were pupils who take part in programming contests. We did not need to listen to something we know for years.

To stop wasting time, I started writing all C++ keywords on a sheet of paper. Well, that wasn’t far more interesting than the lecture, so, I wondered: how many C++ keywords is succession can be a part of a valid C++ program? I started from a simple unsigned long int and ended with this code. It contains a fragment of 33 different keywords that are separated only with spaces and punctuation.

class T /* ignore this line: `class' is followed by `T' which is not a keyword */
  inline void* operator new(unsigned int) {
    if (sizeof(
      unsigned((const wchar_t)
      (reinterpret_cast<long*>(static_cast<signed char>(true) ))))))) {
      do {
      } while (float(false));
    } else {
      for (;;) {
    try {
      return 0;
    } catch (double) {

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s