こんばんは、
解決策: この問題は、アロケーター ctors の明示的なキーワードに起因していました。
編集: ようやく問題を特定できました。カスタム アロケータと一緒に使用すると、unordered_set の移動 ctor から来ているようです。まだ掘っています。
編集: 奇妙なことに、カスタム アロケータと std::vector を使用しても問題はありません。
から要素をコピーしようとすると、エラー メッセージが表示されるのはなぜですか。
typedef std::unordered_set< const CScopeProfiler* > CInternalScopeProfilersSet;
に :
typedef std::unordered_set< const CScopeProfiler*, std::hash< const CScopeProfiler* >, std::equal_to< const CScopeProfiler* >, CAllocator< const CScopeProfiler* > > CScopeProfilersSet;
次のように :
CProfiler::CScopeProfilersSet CProfiler::ScopeProfilersRegistry() const
{
CScopeProfilersSet kSet;
kSet.insert( *( m_pkRegister->begin() ) );
return kSet;
}
正確なエラー メッセージはフランス語で表示されるため、おおよその翻訳は次のようになります。
Error 1 error C2664: 'std::_Hash<_Traits>::_Hash(const std::_Uhash_compare<_Kty,_Hasher,_Keyeq> &,const GameForge::Core::CAllocator<T> &)' : impossible to convert second parameter of 'std::_Wrap_alloc<_Alloc>' to 'const GameForge::Core::CAllocator<T> &' c:\program files (x86)\microsoft visual studio 11.0\vc\include\unordered_set 195 1
kSet.insert() を配置しない場合、エラーは発生しないことに注意してください。
typedef は、CProfiler のスコープで行われます。
私は何日も立ち往生しており、期待どおりにハッシャーから来ているようには見えません。StackOverflow に関する私の最初の投稿であるため、投稿が適切に形成されていない場合は申し訳ありません。
PS : ここで要求されたのは、コード スニペットです。
namespace GameForge
{
namespace Core
{
class CAllocationsHistogram;
// Ensure profiling code isn't profiled.
class GF_API CProfiler
{
public:
class CScopeRun;
class GF_API CScopeProfiler
{
friend CProfiler;
friend CScopeRun;
public:
CScopeProfiler( const char* pcLabel );
~CScopeProfiler();
};
class GF_API CScopeRun
{
friend CProfiler;
public:
CScopeRun( CScopeProfiler& rkScopeProfiler );
~CScopeRun();
};
typedef std::unordered_set< const CScopeProfiler*,
std::hash< const CScopeProfiler* >,
std::equal_to< const CScopeProfiler* >,
CAllocator< const CScopeProfiler* > > CScopeProfilersSet;
private:
typedef std::unordered_set< const CScopeProfiler* > CInternalScopeProfilersSet;
public:
CScopeProfilersSet ScopeProfilersRegistry() const;
protected:
CProfiler();
~CProfiler();
private:
CInternalScopeProfilersSet* m_pkRegister;
};