abseil / abseil/abseil-cpp

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

Aperta
#344 1 commento 1 reazione 0 assegnatari Vedi su GitHub
Lingua principale
C++
Stelle
18.1k
Fork
3.2k
Merge medio
20h 36m
PR unite (30g)
1

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.