std:: pair in unordered map

251 views Asked by At

I've extracted the sections of my code to show what I believe is causing the error.

        typedef unordered_multimap<string , ItemPtr > StringToItemMultiMap;

        void Library::multiMapItemWithKeys ( StringToItemMultiMap * map , ItemPtr itemPtr , StringSet keySet )
    {
        StringSet::iterator it;
        for ( it = keySet.begin ( ); it != keySet.end ( ); ++it )
        {
            pair< string , ItemPtr > aPair ( *it , itemPtr );
            map->insert ( aPair );
        }
    }

I have this operator overload:

    bool operator<(const ItemPtr & ip1, const ItemPtr & ip2)
    {
        bool result;
        if ( ip1.getPtr ( )->getTitle ( ).compare ( ip2.getPtr ( )->getTitle ( ) ) < 0 )
            result = true;
        else
            result = false;
        return result;
    }

This is a typical error:

    1>------ Build started: Project: asgmt04, Configuration: Debug Win32 ------
    1>  Library.cpp
    1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xhash(672): error C2675: unary '++' : 'std::string' does not define this operator or a conversion to a type acceptable to the predefined operator
    1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\unordered_map(632) : see reference to function template instantiation 'void std::_Hash<std::_Umap_traits<_Kty,_Ty,std::_Uhash_compare<_Kty,_Hasher,_Keyeq>,_Alloc,true>>::insert<_Iter>(_Iter,_Iter)' being compiled
    1>          with
    1>          [
    1>              _Kty=std::string
    1>  ,            _Ty=ItemPtr
    1>  ,            _Hasher=std::hash<CustomType>
    1>  ,            _Keyeq=std::equal_to<CustomType>
    1>  ,            _Alloc=std::allocator<std::pair<const std::string,ItemPtr>>
    1>  ,            _Iter=std::string
    1>          ]

Anyone know what is going on?

0

There are 0 answers