I have a piece of templatised C++ code that compiles fine on Visual Studio 2010, but does not compile on Linux GCC. The code looks fine to me, so my question is: what am I doing wrong here?
This is the code that gives the error (I removed all the irrelevant stuff to get just the problematic part):
class CaseInsensitiveCompare
{
public:
bool operator() (const RString& first, const RString& second) const;
};
template <typename T>
T CombinedValue<T>::getUpgradedSettingValue(const T& defaultValue, const UpgradeList& upgrades, const RString& className) const
{
std::map<RString, CombinedSetting<T>, CaseInsensitiveCompare> myMap;
std::map<RString, CombinedSetting<T>, CaseInsensitiveCompare>::iterator myIter;
}
This compiles and functions just fine, but gives a compile error on GCC on Linux. The error I get from the compiler is that there should be a ; before myIter. So the weird thing is that the line with myMap is fine, but the line with myIter is not. If I remove the line with myMap, I still get the exact same issue.
What am I doing wrong here? My current hunch is that this is an error in the GCC compiler itself, but if that is the case: how can I work around that?