1

I am writing a template deriving from STL multimap like this:

template <typename T1, typename T2, typename T3=less<T1> >
class MyMultimap : public multimap<T1, T2, T3> 
{
    public:
    void Set(T1 x, T2 y) {
        for(auto it=this->find(x);it->first==x;++it)
            it->second=y;
    }   
};

In line for(auto it=this->find(x);it->first==x;++it), why should I add this? If I omit it, I get following error:

A.cpp:13:21: error: use of undeclared identifier 'find'
        for(auto it=find(x);it->first==x;++it)
                    ^
                    this->

I am using clang to compile this code. The clang version is:

Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin16.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Yuheng Zou
  • 173
  • 1
  • 9

0 Answers0