abseil / abseil/abseil-cpp

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

Open
#344 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
18.1k
Forks
3.2k
Avg merge
20h 36m
Merged PRs (30d)
1

Description

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.