Are there any advances in recent C++ that allows for differentiating between getting and setting values via the operator[]
of a class? (as Python does via __setitem__
and __getitem__
)
const T& operator[](unsigned int index) const;
T& operator[](unsigned int index);
I am wrapping an std::unordered_map
, and want to let my users access the data via the operator[]
, but also do some behind the scenes record-keeping to keep things aligned in my data structure.
Searching reveals a few answers, but they are all many years old, and I was wondering if C++ has added extra functionality in the meantime.