abseil / abseil/abseil-cpp

API request: an equivalent of boost::intrusive_ptr supported in absl

Đang mở
#344 1 bình luận 1 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C++
Star
18.1k
Fork
3.2k
Merge trung bình
20 giờ 36 phút
Pull request đã merge (30 ngày)
1

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.