Unofficial Hacker News companion — get notified on comment replies, and more.

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

131 points by surprisetalk 6 days ago | lemire.me | 202 comments on HN | Vote on HN (opens Hacker News) |

View full thread · View on Hacker News

Comment thread (4)

  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.
      Replies (1)
      1. I think what I meant was that in the everything is a pointer model, you can solve the problem you mentioned of only having stuff on the heap by also allowing pointers into the stack. You could even do it automatically based on escape analysis maybe.
        Replies (1)
        1. You can allow pointers to the stack, but then you have to do the lifetime analysis to make sure they aren't invalidated due to needing to live longer than your stack does, and promote to the heap in this case.

          It's not that these problems are insurmountable, it's that this was presented as something that simplifies things, but this solution isn't exactly simple.