An unofficial, read-only Hacker News reader.

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

129 points by surprisetalk 3 days ago | lemire.me | 198 comments on HN

View full thread · View on Hacker News

Comment thread (2)

  1. I believe there are also cases where you have a member variable which has a complicated initialization that you may want to handle in some sort of manner that is not appropriate for the default ctor. So you may not want to initialize everything right away in this scenario.
    Replies (1)
    1. Can you give a concrete example? Why wouldn't you initialize the member to something, e.g. a sentinel value?

      Note that if the member is non-trivial, its default constructor is called either way.