There are (at least) two ways to go here.
The first is to make something like a set_row class, which is a proxy. So you'd have something like
class set
{
public:
set_row operator[](size_t row)
{
// Return a proxy object that just sees the correct row.
return set_row(internal_buffer_pointer[row]);
}
...
};
where set_row is something like
class set_row
{
public:
// Ctor takes a row
// Take a column, and return a reference to the correct column in the row.
element &operator[](size_t column);
};
From experience (on, ahem, VisualC++), this was slow, as it will need to construct a proxy object for each access.
The second is to forgo operator[], and use operator():
class set
{
public:
element &operator()(size_t row, size_t col);
...
};
It would be nice using operator[], but, unfortunately, you can't do that with it.
operator []and it should work