![](/img/trans.png)
[英]error C2440: '=': cannot convert from 'std::list<std::string,std::allocator<_Ty>> *'to 'std::string*'
[英]std::allocator<_Ty>::deallocate : cannot convert parameter 1 from 'X' to 'Y'
我正在將一些C ++代碼從VisualStudio 6升級到VisualStudio 2008。
有一個類“GenExportableTree”看起來很像來自Dinkumware的xtree http://www.dinkumware.com/xtree.txt
在編譯包含此GenExportableTree的庫時,我收到以下錯誤:
Error 37 error C2664: 'std::allocator<_Ty>::deallocate' : cannot convert
parameter 1 from 'std::CGenExportableTree<_K,_Ty,_Kfn,_Pr,_A>::_Node *' to
'CCfwSchemaInfo *'
這是以下幾行:
void _Freenode(_Nodeptr _S)
{
allocator.deallocate( _S, 1);
}
一些額外信息:您可以在上面的dinkumware鏈接下找到GenExportableTree的完整實現。
CCfwSchemaInfo即將到來的地方我可以找到以下聲明:
typedef CGenExportableMap<wstring, CCfwSchemaInfo, GenNoCaseWString> CfwSchemaTable;
CGenExportableMap的定義如下:
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;
在最后一行中,GenExportableTree在GenExportableMap定義中使用。
因為之前所有這些都在vs6下正確編譯,我猜其實一切都是正確的 - 可能編譯器現在更嚴格 - 所以我應該從哪里開始尋找編譯器抱怨的錯誤? 我該如何解決這個問題呢?
謝謝!
VC6存在嚴重的模板問題,因此無法根據標准支持分配器。 他們使用了一些早已被刪除的特殊黑客。
如果某些代碼仍依賴於那些非標准接口,我認為您唯一的選擇是修復代碼,使其適用於當前(標准)分配器接口。 抱歉。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.