Hacker News new | past | comments | ask | show | jobs | submit login

Wasn't a lot of memory safety and thread safety introduced in c++14?



C++11 introduced threading and a memory model for C++.

C++14 had relaxed requirements on constexpr, initializers in lambda captures, using auto for return type deductions, and a few other small tweaks.


C++11 had unique_ptr and shared_ptr, but C++14 helped with adding make_unique. In my opinion, that makes a big difference because now making a special unique pointer is an atomic operation in your program.


If only make_unique (and make_shared) worked with uniform initialization...

  struct Foo {
    int i;
    float f;
    bool b;

    // No constructor
  };

  std::make_unique<Foo>(1, 2.3f, true);
Doesn't compile, since make_unique requires an appropriate constructor (see https://isocpp.org/files/papers/n3588.txt for the rationale).

It also doesn't work when Foo's constructor is private, even when called from a function that would have access to this private constructor.

And this is my beef with C++: Yes it's powerful, and I quite like it, but you sooner or later hit these speed bumps that unnecessarily complicate things.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: