shaun Guest
|
Posted: Fri Jan 27, 2006 4:28 pm Post subject: Re: const map templated 'find' |
|
|
| Quote: | template <class S, class T
T constFind(const map< S, T > & theMap, const S & theKey, const T &
errVal){
map< S, T>::const_iterator ppair(theMap.find(theKey));
return (ppair not_eq theMap.end())?(ppair->second):errVal;
}
and then in the body of the code just have
theValue = constFind(myMap, aKey, anErrVal);
on one of my compilers (gcc 3.2.3) this appears to compile (havent tried
running it), on the other (gcc 4.0.0) it doesn't.
Keep 'ppair' an iterator. Let's make it work with that.
V
|
Indeed the compilers gave me a helpful clue, that really what I meant
was:
typename map< S, T>::const_iterator ppair(theMap.find(theKey));
and suddenly all is well.
cheers
shaun
|
|