开发者

"non-existent member function specified as friend" -?

开发者 https://www.devze.com 2023-01-03 20:41 出处:网络
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 m

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 voi开发者_运维技巧d 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 ...


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...]
    }};


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

0

精彩评论

暂无评论...
验证码 换一张
取 消