S
Stuart Moore
Hi, I'm quite new to templates and I seem to be getting myself messed
up. I want to write a function that takes a map<T, int> and a set<T>,
iterates over the set, and increments the corresponding int in the map
(or sets it to 1 if it doesn't already exist).
I can write the function itself for a given type, but I can't figure out
what template statement(s) I need to put before it to make it
generalise. Stuff I've tried unsuccessfully is below.
Any help much appreciated; please reply to the group as email address is
invalid.
template <typename T>
void increment(map<T, int>& theMap, const set<T> theSet){
...
}
template <typename T, template <T, int> class map, template <T> class set>
void increment(map<T, int>& theMap, const set<T> theSet){
...
}
up. I want to write a function that takes a map<T, int> and a set<T>,
iterates over the set, and increments the corresponding int in the map
(or sets it to 1 if it doesn't already exist).
I can write the function itself for a given type, but I can't figure out
what template statement(s) I need to put before it to make it
generalise. Stuff I've tried unsuccessfully is below.
Any help much appreciated; please reply to the group as email address is
invalid.
template <typename T>
void increment(map<T, int>& theMap, const set<T> theSet){
...
}
template <typename T, template <T, int> class map, template <T> class set>
void increment(map<T, int>& theMap, const set<T> theSet){
...
}