3 ms·
In that case C++ has garbage collection too with std::shared_ptr. I guess 1 is a count too so also with std::unique_ptr.
by sqeaky 10y ago
In that case C++ has garbage collection too with std::shared_ptr. I guess 1 is a count too so also with std::unique_ptr.
- WildUtah 10y agoIndeed, according to these "ref counting is gc" folks, free(void *) is a garbage collector, so C has always been garbage collected since 1970.
- pjmlp 10y agoNo, because the language C doesn't provide any of the algorithms described here: http://gchandbook.org http://gchandbook.org Although, there are conservative GCs for C that replace malloc () and make fre () a nop, they cannot release all memory properly due to C semantics.
- sqeaky 10y agoI am pretty WildUtah was being sarcastic to be a more extreme version of my post. Or perhaps it was an attempt to expand the grey area.
- hellofunk 10y agoAnd technically, also unique_ptr, which has a reference count of 1 or 0.
- pjmlp 10y agoC++ has a GC ABI introduced in C++11 and the dialects C++ Builder, C++/CLI and C++/CX do have GC support at language level. Library types like std::shared_ptr don't really count to say that a language has a GC, because their use, specially their correct use, is not enforced by the compiler.