Garbage Collection in C++ — why?

后端 未结 16 2150
北恋
北恋 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 committee isn't adding garbage-collection, they are adding a couple of features that allow garbage collection to be more safely implemented. Only time will tell whether they actually have any effect whatsoever on future compilers. The specific implementations could vary widely, but will most likely involve reachability-based collection, which could involve a slight hang, depending on how it's done.

    One thing is, though, no standards-conformant garbage collector will be able to call destructors - only to silently reuse lost memory.

提交回复
热议问题