[ref_counter] Make ref_counter an abstract base class.

Forces people to override correctly.

Also make no_op_ref_counter final.
This commit is contained in:
Joe Thornber 2020-04-08 12:22:28 +01:00
parent 501299a4ee
commit 1481ed0f8a

View File

@ -30,13 +30,18 @@ namespace persistent_data {
boost::shared_ptr<ref_counter<ValueType> > ptr;
virtual ~ref_counter() {}
virtual void set(ValueType const &v, uint32_t rc) {}
virtual void inc(ValueType const &v) {}
virtual void dec(ValueType const &v) {}
virtual void set(ValueType const &v, uint32_t rc) = 0;
virtual void inc(ValueType const &v) = 0;
virtual void dec(ValueType const &v) = 0;
};
template <typename ValueType>
class no_op_ref_counter : public ref_counter<ValueType> {
class no_op_ref_counter final : public ref_counter<ValueType> {
public:
virtual void set(ValueType const &v, uint32_t rc) {}
virtual void inc(ValueType const &v) {}
virtual void dec(ValueType const &v) {}
};
}