Boost 1.59编译错误
Boost 1.59 compile error
将文件更新到boost_1.59.0
后,我出现了一个动态错误。我不明白出了什么问题,因为在1.43增压中,所有工作都很好。
这是我的助推宣言和我的功能。
boost::unordered_map<VID, size_t>::iterator iterTargetMap = rSkillUseInfo.TargetVIDMap.find(TargetVID);
if (rSkillUseInfo.TargetVIDMap.end() != iterTargetMap)
{
size_t MaxAttackCountPerTarget = 1;
switch (SkillID)
{
case SKILL_SAMYEON:
case SKILL_CHARYUN:
MaxAttackCountPerTarget = 3;
break;
}
if (iterTargetMap->second >= MaxAttackCountPerTarget)
{
sys_log(0, "SkillHack: Too Many Hit count from SkillID(%u) count(%u)", SkillID, iterTargetMap->second);
return false;
}
iterTargetMap->second++;
}
else
{
rSkillUseInfo.TargetVIDMap.insert( std::make_pair(TargetVID, 1) );
}
我还在c++11 中试用了auto
auto iterator iterTargetMap = rSkillUseInfo.TargetVIDMap.find(TargetVID);
这是我的错误日志gcc49http://pastebin.com/p1KLqs9H我不能在这里写——错误太大了。
我被这个错误困扰了4天(
这是视频
class VID
{
public:
VID() : m_id(0), m_crc(0)
{
}
VID(DWORD id, DWORD crc)
{
m_id = id;
m_crc = crc;
}
VID(const VID &rvid)
{
*this = rvid;
}
const VID & operator = (const VID & rhs)
{
m_id = rhs.m_id;
m_crc = rhs.m_crc;
return *this;
}
bool operator == (const VID & rhs) const
{
return (m_id == rhs.m_id) && (m_crc == rhs.m_crc);
}
bool operator != (const VID & rhs) const
{
return !(*this == rhs);
}
operator DWORD() const
{
return m_id;
}
void Reset()
{
m_id = 0, m_crc = 0;
}
private:
DWORD m_id;
DWORD m_crc;
};
通过查看错误,您似乎必须为类型VID定义一个hash函数,才能将其用作映射中的键。
STL中已经为基本类型定义了标准散列函数,但您必须为自己的域类型定义一个特定的散列函数。
通常,做这样的事情就足够了:
namespace std {
template<> struct hash<VID> {
using argument_type = VID;
using result_type = std::size_t;
result_type operator()(argument_type const& vid) const {
// what to put here depends on the type of VID
// and how you want to create the hash
}
};
}
困难通常在于理解如何创建散列。根据我的经验,对于用户定义的类,我曾经对一些数据成员(最重要的数据成员)使用过标准专业化。
在您的情况下,例如,您可以将DWORD
强制转换为几个unsigned int
,并使用它们通过使用std::hash<unsigned int>
来获取哈希(我假设这是来自Windows API的DWORD,据我记忆,这是一个32位无符号整数)。
如评论中所述,请参阅此处了解更多详细信息。
相关文章:
- 用MacOS Mojave编译C++:致命错误:mpi.h:没有这样的文件或目录
- std::is_base_of表示ctor编译错误
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- 在没有定义返回类型的函数中返回布尔值,并将结果保存在无错误的char编译中-为什么
- Qt5:使用QCommandLineParser类时出现奇怪的编译错误
- Qt Cmake 错误编译"GuiSupportQt not found"
- Opengl 精度转换错误编译错误 E0415
- 库将ARM架构错误编译为架构X64
- RT 音频 Mac 错误 g++ 编译错误
- 错误编译Boost.log
- 错误编译QT创建者 / QT窗口小部件示例
- 错误编译MIPS32
- Visual Studio 2013 中的错误(编译和运行代码)
- 链接错误编译qt项目在visual 2010
- 无法用模板错误编译nsgmls
- 奇怪的错误.编译失败
- 如果有人调用c++中的方法,则强制错误(编译时)
- 来自autoconf测试的错误编译命令
- 时间限制超出错误C++编译
- SFML 2.3 和 CodeBlocks 错误编译