::在std之前使用::: std :: mutex意味着什么

Ray*_*ton 3 c++ std

我正在阅读mongo资源代码,正在阅读using ::std::mutex,但我不知道这是什么意思?

namespace stdx {

using ::std::mutex;            // NOLINT
using ::std::timed_mutex;      // NOLINT
using ::std::recursive_mutex;  // NOLINT

using ::std::adopt_lock_t;   // NOLINT
using ::std::defer_lock_t;   // NOLINT
using ::std::try_to_lock_t;  // NOLINT

using ::std::lock_guard;   // NOLINT
using ::std::unique_lock;  // NOLINT

}
Run Code Online (Sandbox Code Playgroud)

Dio*_*cus 9

领先::意味着编译器应该开始从全局范围中寻找实例化对象的定义。

因此using ::std::mutex意味着从全局范围开始,转到std名称空间并mutex在当前名称空间中使用类stdx

  • @MichalŠtein-“正确”在某种程度上衡量了赞誉。所有好的答案都是正确的。选中标记仅表示它对问题的发布者有帮助。它不会赋予其他“正确性”。 (2认同)