Re: Template Help: Map<T, int> and Set<T>
Stuart Moore wrote:
On 06/06/06 17:56, Victor Bazarov wrote:
This compiles for me (with proper includes):
template<class T> void increment_or_assign(std::map<T,int> &m,
std::set<T> const& s)
{
// whatever...
}
Thank you. It seems my problem is different to what I thought in that
case. As you say,
template <typename T>
void increment(map<T, int>& theMap, const set<T>& theSet){
};
compiles, but
template <typename T>
void increment(map<T, int>& theMap, const set<T>& theSet){
set<T>::const_iterator itr;
Read about dependent names. And then add 'typename' before this
declaration.
};
Doesn't - instead I get
error: expected `;' before "itr"
Replacing T with a specific class all the way through compiles again.
How should I be obtaining an iterator for the set?
You almost got it right.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask