I would like to inherit from a class with the const
specifier like this:
class Property
{
int get() const;
void set(int a);
};
class Co
I had the need for a related problem, which is: to really control/highlight mutable and const access on some class. I did it with this simple reusable template wrapper:
template
class TAccessor : private T
{
public:
const T& Const() const { return *this; }
T& Mutable() { return *this; }
};
// Example of use:
template
using MyVector = TAccessor>;
void main()
{
MyVector vector;
vector.Mutable().push_back(10);
int x = vector.Const()[1];
...
}