top | item 45859546

(no title)

medler | 3 months ago

The new changes in C++14, 17, and 20 are really nice. It feels like the language keeps getting cleaner and easier to use well

discuss

order

spacechild1|3 months ago

Yes! Just to list a few personal highlights:

C++14:

  - generalized lambda capture
  - generic lambdas
C++17:

  - structured bindings
  - init statement for if
  - class template argument deduction (CTAD)
  - std::string_view
  - std::filesystem
  - std::variant
  - std::optional
  - std::to_chars() and std::from_chars()
C++20:

  - std::format
  - coroutines (makes ASIO code so much cleaner!)
  - concepts
  - std::span
  - bit manipulation (<bit>)
  - std::bind_front
  - std::numbers (math constants)

mrlongroots|3 months ago

Same, I don't understand the complaints against modern C++. A lambda, used for things like comparators etc, is much simpler than structs with operators overloaded defined elsewhere.

My only complaint is the verbosity, things like `std::chrono::nanonseconds` break even simple statements into multiple lines, and you're tempted to just use uint64_t instead. And `std::thread` is fine but if you want to name your thread you still need to get the underlying handle and call `pthread_setname_np`. It's hard work pulling off everything C++ tries to pull off.