language: C++ 4.7.2 (gcc-4.7.2)
date: 180 days 14 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 
template<typename T, unsigned int n>
struct ArrayWrapper
{
    T v[n];
    T& operator[](unsigned int i) { return v[i]; } // You can also check for out-of-bounds errors
    const T& operator[](unsigned int i) const { return v[i]; } // You can also check for out-of-bounds errors
};
#include <map>
#include <iostream>
int main()
{
    typedef std::map<size_t, ArrayWrapper<double,2> > Map;
    Map trace;
    trace[1][0] = 42;
    for(Map::const_iterator it = trace.begin(); it != trace.end(); ++it)
        std::cout << "( " << (*it).first
            << ", " << (*it).second[0]
            << ", " << (*it).second[1]
            << ")\n";
}