3

I'm reading mongo resource code, reading using ::std::mutex, but I don't know what's the meaning?

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

}
Tejendra
  • 1,874
  • 1
  • 20
  • 32

1 Answers1

9

Leading :: means compiler should start looking for definition of instantiated object from global scope.

Hence using ::std::mutex means starting from global scope, go to std namespace and use mutex class in current namespace stdx.

Diodacus
  • 663
  • 3
  • 8
  • Correct. This should be the correct answer. – DexterHaxxor May 20 '19 at 05:10
  • 2
    @MichalŠtein - "Correct" is in part a measure of upvotes. All good answers are correct. The checkmark only means it helped the poster of the question personally. It does not bestow additional "correctness". – StoryTeller - Unslander Monica May 20 '19 at 05:28
  • Really? Do you need a screenshot, @StoryTeller, to see that the little checkbox says something about a correct answer when hovered on? Also, did you know that words can have more than one meaning? "Correct" was meant not to signify the correctness of the statements in the answer, but to signify that the answer was what the asker wanted to know. I if I knew you take every word literally, I'd write "an answer that correctly answers the question while being simple and accurate". – DexterHaxxor May 20 '19 at 13:24
  • @MichalŠtein - Yes, do please be precise in your language on SO, lest you mislead the uninitiated. That will be better all around. – StoryTeller - Unslander Monica May 20 '19 at 13:27