I have a large database of tennis match reords played in the ATP and WTA tours over several years. I am going through these to generate a match history for each player in each year in each tour. I have 5 years of data and 4 tours (hence the dimensions in the declaration below). I want to do a typedef not just for these specified dimensions, but in general so I can declare another Array2DPlayerHistoryMap object, but if I don't put in a dimension the compiler compains. How can I do the 2nd and 3rd lines for the general case?

typedef map<string,set<MatchRecordPointer>> PlayerHistoryMap;
typedef array<PlayerHistoryMap,5> ArrayOfPlayerHistoryMap;
typedef array<ArrayOfPlayerHistoryMap,4> Array2DPlayerHistoryMap;
Array2DPlayerHistoryMap PlayerMatchHistory;

If you don't know ahead of time what size you need for the arrays, then you need to use a dynamic array type instead of std::array (which is only for static size arrays). The class you can use is std::vector (see docs). This would make your lines look like this:

typedef map<string,set<MatchRecordPointer>> PlayerHistoryMap;
typedef vector<PlayerHistoryMap> ArrayOfPlayerHistoryMap;
typedef vector<ArrayOfPlayerHistoryMap> Array2DPlayerHistoryMap;
Array2DPlayerHistoryMap PlayerMatchHistory;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.