An unofficial, read-only Hacker News reader.

In C++, = default and {} are not the same constructor (opens external site)

131 points by surprisetalk 4 days ago | lemire.me | 198 comments on HN

View full thread · View on Hacker News

Comment thread (1)

  1. > It is up to the constructor to only initialize storage, or do whatever it feels like to have values assigned to it.

    Right, see the "I guess the argument might be" part above... I find this to be a very questionable design choice, leaving you to have to go and read a header somewhere to determine whether `Foo f;` is safe or not. But it's not really a choice, is it? C++ had to do it this way to be compatible with how C programs were written back in the 1970s.

    > By the way, already in the 16 bit days you could configure to have warnings as errors for variables being used without initialisation.

    Ah yes, the "but C can be configured to be not-insane" argument, one of my favorite pjmlp-isms, right up there with "but $LANG's compiler is written in C++" and "but you already get memory safety with a GC". Keep on doing you!