Garbage Collection in C++ — why?

后端 未结 16 2154
北恋
北恋 2020-11-29 18:32

I keep hearing people complaining that C++ doesn\'t have garbage collection. I also hear that the C++ Standards Committee is looking at adding it to the language. I\'m afrai

16条回答
  •  盖世英雄少女心
    2020-11-29 18:47

    The motivating factor for GC support in C++ appears to be lambda programming, anonymous functions etc. It turns out that lambda libraries benefit from the ability to allocate memory without caring about cleanup. The benefit for ordinary developers would be simpler, more reliable and faster compiling lambda libraries.

    GC also helps simulate infinite memory; the only reason you need to delete PODs is that you need to recycle memory. If you have either GC or infinite memory, there is no need to delete PODs anymore.

提交回复
热议问题