Hacker News new | past | comments | ask | show | jobs | submit login
C++ tricks (codeforces.com)
6 points by wojciem on June 21, 2015 | hide | past | favorite | 2 comments



'tricks' indeed. Don't get me wrong, if one is still stuck in the pre-C++-11 era this could open a lot of gates into unexplored yet exciting new territory and it does provide reasonable code samples, yet I wouldn't recommend this for learning C++ as it also introduces some bad habits. For example

- in 1 all variable declarations and initializations are split. That seems to stem from pre-C99 and makes no sense, especially not when they are on consecutive lines anyway.

- 3 'simply use #include <bits/stdc++.h>' No, don't do that. Instead properly learn what each header is for. Moreover it's not even a standard header so non-portable.

- 4 'hidden functions' Again non-portable and doesn't have much to do with c++ anyway

- '" \n"[j == m]' yes that's a trick to have save one line of code at the expense of being hard to understand and way more error prone

- '#define mt make_tuple' why would you obscure your code like that by saving 8 or so characters


>#include <bits/stdc++.h>

This is a very cool trick to turn your compile time from seconds to minutes.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: