C++11 introduced an interface to garbage collectors. From what I see, it provides a standardized way to communicate with the GC (e.g. declare_no_pointers), and to get information about how disguised pointers are handled (e.g., get_pointer_safety).
However, there is no standardized way in C++11 yet to allocate a raw block of memory, which you don't have to free manually. There are use cases where that would help, even if destructors are not called. One example is to implement efficient concurrent data structures (as mentioned by Herb Sutter) without having to deal with complicated cleanup protocols.
So far, so good. My question (from the perspective of an ordinary develper, not a GC library developer):
Is there a real-world example where the new C++11 GC interface has helped you?
At least from my perspective the world has not changed. If you need GC, you still have to find a non-standard library, for example Boehm GC, and learn how to integrate and use it. The new standardized interface won't help very much in that respect. It will also not solve portability issues.
(In the long term, the common interface defined by the C++11 standard hopefully pays off. However, my question targets only the immediate future.)
No, there is no currently practical usage of C++11 GC interface as there is no compiler which fully supports this API in the meantime. Also, C++11 standard declares this API as optional and there is no movement seen to implement it in the major compilers (but as Jesse Good notes MSVC already does support it).
Also you should look this post, it has related information: Why garbage collection when RAII is available?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With