API request: an equivalent of boost::intrusive_ptr supported in absl
- 主要言語
- C++
- スター
- 18.1k
- フォーク
- 3.2k
- 平均マージ
- 20時間 36分
- マージ済み PR(30日)
- 1
説明
I have a data structure with a high cardinality. and I want to be able to keep it weakly in a set, returning ref-counted pointers to it to callers. When all the callers drop their refs, I need to remove it from the set. I can easily accomplish this with std::shared_ptr and std::weak_ptr, or using std::enable_shared_from_this. However those options consume excess memory.
https://www.boost.org/doc/libs/1_70_0/libs/smart_ptr/doc/html/smart_ptr.html#intrusive_ptr is a better solution, but comes with the baggage of, well, boost :) Also see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0406r1.html
See also a proposed use-case (and a home-grown workaround) in an Envoy Proxy PR: https://github.com/envoyproxy/envoy/pull/7364/files/2de13dd52a0428838a8b3ab2656035956805791e It would be better not to maintain this shared_ptr replacement in Envoy long-term. This feels in-line with absl's pattern of providing generally useful functionality.
コントリビューションガイド
評価
この issue はまだ評価されていません。