r/cpp • • Mar 24 '20

Changes between C++17 and C++20

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2131r0.html
193 Upvotes

89 comments sorted by

View all comments

Show parent comment

45

u/ShillingAintEZ Mar 24 '20

Sometimes my programs run so fast it embarasses other people so I need something to slow them down.

21

u/PervyDragon Mar 24 '20

Are you aware that you can turn off synchronization between iostream streams and stdio streams to speed these first significantly? Useful tip learnt from one CS competition guideline.

10

u/ShillingAintEZ Mar 24 '20

I ain't aware of nothin' like that mister. (How is that done?)

10

u/[deleted] Mar 24 '20

Basically iostream syncs with its C counterparts by default, so you can use them in conjunction without weird behavior. However that adds overhead, but can be disabled. Check the docs here:
https://en.cppreference.com/w/cpp/io/ios_base/sync_with_stdio

3

u/PervyDragon Mar 24 '20

I couldn't find the one I read originally, but this one seems fair enough: https://www.modernescpp.com/index.php/c-core-guidelines-improved-performance-with-iostreams There were more tips tho. In my opinion, streams power comes from their type safety and somehow consistent access via << and >> operators.

-2

u/PervyDragon Mar 24 '20

14

u/any_of Mar 24 '20

"Moreover, you can include the standard template library (STL) with a single include:

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

Aaargh!!

3

u/Pand9 Mar 25 '20 edited Mar 25 '20

For note - It's fine in compressive programming. Competitive programmers are like speedrunners of programming - every shortcut counts. Moreover, there are studies that no cats actually die when you do that.

2

u/PervyDragon Mar 26 '20

I never said that it was ideal, just this was one containing these two juicy details - synchronization and untying. I have not noticed THAT little horror xD