スマート ポインター クラスを作成し、組み込みの Visual Studio STL 実装でそれを使用して大きな成功を収めています。
問題は、パフォーマンスのボトルネックが Linux から移植されたコードの STL ライブラリにあることに気付いたことです (STL は、私たちが使用している方法よりも大幅に高速です)。そのため、STLPort にリンクして、パフォーマンスの問題に対処できるかどうかを確認しようとしています。
ただし、STLPort 5.2.1 を使用すると、あいまいなコピー コンストラクターに関連する非常に奇妙なビルド エラーが発生します。私はそれを50行のC++プログラムに落としました
#include "stdafx.h"
#include <set>
using namespace std;
template<class T>
class CRefCountPtr
{
public:
CRefCountPtr(T* pT) : m_T(pT)
{
}
T** operator&()
{
return &m_T;
}
operator T*() const
{
return (T*)m_T;
}
bool operator< (T* pT) const
{
return m_T < pT;
}
T* m_T;
};
class Example
{
int example;
};
int _tmain(int argc, _TCHAR* argv[])
{
set< CRefCountPtr<Example> > blah;
Example ex;
blah.insert(&ex);
return 0;
}
VS2008SP1 から返されるエラーは
stlport\stl\_tree.h(318) : error C2782: 'void stlp_std::_Copy_Construct(_Tp *,const _Tp &)' : template parameter '_Tp' is ambiguous
stlport\stl\_construct.h(130) : see declaration of 'stlp_std::_Copy_Construct'
could be 'CRefCountPtr<T>'
with
[
T=Example
]
or 'Example *'
.....
stlport_example.cpp(43) : see reference to class template instantiation 'stlp_std::set<_Key>' being compiled
with
[
_Key=CRefCountPtr<Example>
]
私はここでどのように進めるかについて行き詰っています.これで何が起こっているのか誰か分かりますか?