khokho's blog

By khokho, history, 6 years ago, In English

Are you tired of writing make_pair and not being able to use auto-s on some judges? Well introducing one line of code which will solve all your problems:

#pragma GCC diagnostic warning "-std=c++11"

So hurry up and use it already.

This trick will probably work on 99% of sites.

  • Vote: I like it
  • +84
  • Vote: I do not like it

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Странно что работает: https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html: по механизму, это расчитано только на опции предупреждения, причём на фрагменты файла (обращаем внимание на push и pop), поэтому этот флаг не должен прям работать...

It's quite strange that it's working: https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html by the docs, it should work only with warnings on given file segments (mind push and pop), so that it shouldn't work with std flag...

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    В дополнение к этому, у меня этот трюк не работает с GCC 7: он и так принимает циклы и auto потому что что он использует 11 стандарт по умолчанию, а попытка заиспользовать С++17 через прагму провалилась.

    On top of that, it's not working for me in GCC 7: while it actually accepts for-loops and autos, that's because it uses C++11 by default; trying to provide pragma for C++17 and use it's features failes miserably.

»
6 years ago, # |
  Vote: I like it +28 Vote: I do not like it

You're late, I'm already tired of not being able to use for (auto& [key, value]: map).

»
6 years ago, # |
  Vote: I like it +34 Vote: I do not like it

When people say something works in 99% cases, it's usually around half.

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +28 Vote: I do not like it

    Well it worked on my national olympiad so it's 100% for me currently