1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
struct col_major {};
struct row_major {};
template<class T, class Order>
class Array_2d
{
public:
value_type& operator()(int r, int c)
{
return access(r,c,Order());
}
value_type operator()(int r, int c) const
{
return access(r,c,Order());
}
private:
value_type& access(int r,int c, col_major const&)
{
return /* code column major */;
}
value_type& access(int r,int c, row_major const&)
{
return /* code row major */;
}
value_type access(int r,int c, col_major const&) const
{
return /* code column major */;
}
value_type access(int r,int c, row_major const&) const
{
return /* code row major */;
}
}; |