concurrent_deferred_rc
concurrent_deferred_rc copied to clipboard
how about not use this char array storage, it lose type info, is not easy to debug
https://github.com/cmuparlay/concurrent_deferred_rc/blob/f1fb49b36a8a3cd60be3b816db9922c4ed5faf4b/include/cdrc/internal/counted_object.h#L22
That's a reasonable point. The member can not just be an ordinary T
object since we need to be able to manually control the construction and destruction. The two main ways to achieve this are either:
- using an aligned char array (here)
- by using a single-member union, i.e.,
union { T value; }
The union member acts like an ordinary member except that we are responsible for manually constructing and destructing it. When I last looked at libc++, libstdc++, and Microsoft STL's implementation of std::shared_ptr
, both of these techniques were used by at least one of them, so neither seems strictly preferred. The union would be easier to debug though, so we could switch to that.
If you want to Pull Request that change I'll take it. Otherwise I can do it myself at some point, but it might be a bit later since I am busy right now.