views:

46

answers:

2

Hi, I'm trying to compile CSSTidy with Visual Studio.

The problem is that it throws

error C2245: non-existent member function 'umap::erase' specified as friend (member function signature does not match any overload)

pointing to the

friend void umap<keyT,valT>::erase(const typename umap<keyT,valT>::iterator& it);

which is a declaration in iterator class declared in umap class.

Can anybody tell me where should I digg into to figure out what the problem really is? AFAIK the source compiles in MinGW ...

A: 

source compiles in MinGW

Erm.. so?

Is there a umap erase member function visible to the compiler when it's compiling the inner class?

Billy3

Billy ONeal
yup, it's public one. as I stated before, MinGW compiles it ... that's strange for me.
migajek
Can you post the method that you'd like that to match? Is the declaration located before or after the `friend` declaration? (MinGW is lax about enforcing the function prototype rule)
Billy ONeal
A: 

The fix, forward declare "class iterator;" at the top of class umap, and move the impl of "class iterator" to the bottom of class umap. The reason, MickySoft VS appears to have a deficiency that causes it not recognize umap::erase declared below the impl of umap::iterator.

template <class keyT, class valT>
class umap 
{
    typedef map<keyT,valT> StoreT;
    typedef std::vector<typename StoreT::iterator> FifoT;
private:
    FifoT sortv;
    StoreT content;

public:

    class iterator;

    [...snip...]

  void erase(const typename umap<keyT,valT>::iterator& it)
  {
   content.erase(*it.pos);
   sortv.erase(it.pos);
  }

    [...snip...]

    // Iterator

    class iterator
    {
    [...snip...]
    }};
Chris Brown