
I would add IncrementPolicy with following default.
struct trivial_increment_policy { void inc( long& c ) { ++c; } bool dec( long& c ) { return --c == 0; } }
Now you can add your own
I considered this, but for some reason there's no policies in shared_ptr, so I decided not to add one too. I think counter should belong to policy too (but no-copying is still up to intrusive_pointee_base). struct trivial_increment_policy { void inc() { ++c; } bool dec() { return --c == 0; } int c; } template<class Derived, template IncrementPolicy=trivial_increment_policy> class intrusive_pointee_base { private: typedef intrusive_pointee_base self; protected: intrusive_pointee_base(void) : reference_counter_() {} intrusive_pointee_base(self const&) : reference_counter_() {} self &operator=(self const&) { return *this } ~intrusive_pointee_base(void) {} ... private: mutable IncrementPolicy reference_counter_; };