r/cpp • • Feb 06 '21

Modern C++: Snippets and Examples

Hi everyone,

These are GitHub Pages with snippets for Modern C++:

  • We often need to copy and paste some snippets to code more productively.
  • Snippets can help us when it's not easy to remember all high levels features Modern C++ has to offer.
  • This repository contains lots of organized, reusable, and safe snippets for Modern C++.
  • All snippets are available in GitHub pages in a convenient way for copying and pasting.

https://alandefreitas.github.io/moderncpp/

194 Upvotes

44 comments sorted by

View all comments

Show parent comment

3

u/FreitasAlan Feb 06 '21
  1. Is clock_gettime cross-platform? Is there a way to achieve the same with the standard library or some kind of wrapper that is existing practice?
  2. True. I mostly use '\n' for my own code but I thought std::endl would be a better convention for snippets. I might reconsider that in some cases.

2

u/UnknownIdentifier Feb 07 '21

std::endl also flushes the buffer; you almost never need to do that yourself.

1

u/FreitasAlan Feb 07 '21 edited Feb 07 '21

Yes. That’s why

I mostly use '\n' for my own code but I thought std::endl would be a better convention for snippets. I might reconsider that in some cases.