fork download
  1.  
  2. template<typename T, unsigned int n>
  3. struct ArrayWrapper
  4. {
  5. T v[n];
  6. T& operator[](unsigned int i) { return v[i]; } // You can also check for out-of-bounds errors
  7. const T& operator[](unsigned int i) const { return v[i]; } // You can also check for out-of-bounds errors
  8. };
  9. #include <map>
  10. #include <iostream>
  11. int main()
  12. {
  13. typedef std::map<size_t, ArrayWrapper<double,2> > Map;
  14. Map trace;
  15. trace[1][0] = 42;
  16. for(Map::const_iterator it = trace.begin(); it != trace.end(); ++it)
  17. std::cout << "( " << (*it).first
  18. << ", " << (*it).second[0]
  19. << ", " << (*it).second[1]
  20. << ")\n";
  21. }
Success #stdin #stdout 0.02s 2816KB
stdin
Standard input is empty
stdout
( 1, 42, 0)