std::_Atomic_thread_fence(大写字母 A)是否正确?

std::_Atomic_thread_fence (with capital A) is this correct?

Visual Studio 2012 c++ 文档指出 _ReadBarrier_WriteBarrier 内在函数现在是 deprecated:

The _ReadBarrier, _WriteBarrier, and _ReadWriteBarrier compiler intrinsics and the MemoryBarrier macro are all deprecated and should not be used. For inter-thread communication, use mechanisms such as atomic_thread_fence and std::atomic<T> that are defined in the C++ Standard Library Reference. For hardware access, use the /volatile:iso compiler option together with the volatile (C++) keyword.

按照指示,然后我跳转到 atomic_thread_fence documentation,它指出函数是在 header <atomic> 上定义的。 如果我在我的解决方案中包含这样的 header,我找不到该函数,但我确实找到了 std::_Atomic_thread_fence

命名表明这是一个 Microsoft-specific 实现。这是文档问题还是我应该修改默认的 #include 搜索路径?

这似乎只是 Visual Studio 智能感知的问题。如果您将其更正为 atomic_thread_fence,它应该会按预期工作。