开发者

std::allocator<_Ty>::deallocate : cannot convert parameter 1 from 'X' to 'Y'

I'm upgrading some C++ code from VisualStudio 6 towards VisualStudio 2008.

There is a class "GenExportableTree" which looks a lot like xtree from Dinkumware http://www.dinkumware.com/xtree.txt

When compiling the library which contains this GenExportableTree, I get the following error:

Error   37  error C2664: 'std::allocator<_Ty>::deallocate' : cannot convert 
parameter 1 from 'std::CGenExportableTree<_K,_Ty,_Kfn,_Pr,_A>::_Node *' to 
'CCfwSchemaInfo *'  

which are the following lines:

void _Freenode(_Nodeptr _S)
        {
            allocator.deallocate( _S, 1); 
        }

Some extra info: The you can find the complete implementation of the GenExportableTree under the dinkumware link above.

Where the CCfwSchemaInfo comes around the corner I can find following declarations:

typedef CGenExportableMap<wstring, CCfwSchemaInfo, GenNoCaseWString> CfwSchemaTable;

The definition of the CGenExportableMap is as follows:

template<class _K, class _Ty, class _Pr = less<_K>,
    class _A = allocator<_Ty> >
    class CGenExportableMap {
public:
    typedef CGenExportableMap<_K, _Ty, _Pr, _A> _Myt;
    typedef pair<const _K, _Ty> value_type;
....
....

    typedef _K key_type;
    typedef _Ty referent_type;
    typedef _Pr key_compare;
    typedef _A allocator_type;
    typedef  typename _A::reference _Tref;
    typedef CGenExportableTree<_K, value_type, _Kfn, _Pr, _A> _Imp;

In this last line is where the GenExportableTree gets used in the GenE开发者_开发技巧xportableMap definition.

As this previously all compiled correctly under vs6, I guess actually everything is correct - probably the compiler is just more strictly now - so where should I start looking to find the error the compiler is complaining about? And how should i resolve this one?

Thanks!


VC6 had serious template problems so it couldn't support allocators according to the standard. They used a couple of special hacks that have long since been removed.

If some code still depends on those non-standard interfaces, I think your only option is to fix the code so it works with the current (standard) allocator interface. Sorry.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜