4 refactoring visual-studio c++17
我注意到在c ++ 17中binary_function被删除了。我不知道如何解决它。有人可以帮我改变结构吗?谢谢
我尝试通过谷歌搜索但找不到解决方案。Visual Studio 2019,C++17
struct FGuildCompare : public std::binary_function<CGuild*, CGuild*, bool>
{
bool operator () (CGuild* g1, CGuild* g2) const
{
if (g1->GetLadderPoint() < g2->GetLadderPoint())
return true;
if (g1->GetLadderPoint() > g2->GetLadderPoint())
return false;
if (g1->GetGuildWarWinCount() < g2->GetGuildWarWinCount())
return true;
if (g1->GetGuildWarWinCount() > g2->GetGuildWarWinCount())
return false;
if (g1->GetGuildWarLossCount() < g2->GetGuildWarLossCount())
return true;
if (g1->GetGuildWarLossCount() > g2->GetGuildWarLossCount())
return false;
int c = strcmp(g1->GetName(), g2->GetName());
if (c>0)
return true;
return false;
}
};
Run Code Online (Sandbox Code Playgroud)
std::binary_function 已删除
添加的全部std::binary_function是三个 typedef;并且(在许多情况下)现在可以推断出这些类型。只需从 中删除继承即可std::binary_function。
如果您需要代码在 C++17 之前仍然可以工作,请将这些添加到您的类中:
typedef CGuild* first_argument_type;
typedef CGuild* second_argument_type;
typedef bool result_type;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1689 次 |
| 最近记录: |