An unofficial, read-only Hacker News reader.

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

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

View full thread · View on Hacker News

Comment thread (4)

  1. I feel like this is leaving out the option of only ever referring to objects by a pointer. this means there's no shenanigans around moving or copying things around, and language semantics can still enforce single owners etc. The main disadvantage to this is that it makes any copying explicit, and introduces some (IMO fairly minor) sharp edges around accidentally modifying objects passed into functions etc.
    Replies (1)
    1. It also makes everything heap allocated and prevents dense representations, both of which are not good for performance.
      Replies (1)
      1. Could point to memory from alloca
        Replies (1)
        1. That doesn’t give you the lifetime freedom aspects of the heap, which is what’s required to not think about it.