【问题标题】:Comparing std::addressof() with hexadecimal number将 std::addressof() 与十六进制数进行比较
【发布时间】:2014-08-12 06:27:21
【问题描述】:

我怎样才能使下面的代码工作?

for (auto f=face.begin(); f!=face.end(); ++f)
{
    if (std::addressof(*f) == 0x18b9160) // error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    {
        cout << "found";
    }
}

【问题讨论】:

  • 比较有什么用(假设你可以编译)?
  • @Praetorian:这是调试我的代码所必需的。
  • 然后只需使用演员表:if ((void*)std::addressof(*f) == (void*)0x18b9160)

标签: c++ c++11 reference comparison hex


【解决方案1】:
if (std::addressof(*f) == (void*)0x18b9160)

【讨论】:

    猜你喜欢
    • 2021-08-26
    • 2011-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-24
    • 2019-07-24
    • 2017-09-27
    相关资源
    最近更新 更多