Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does :: mean when used before std like ::std::mutex [duplicate]

Tags:

c++

std

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

}
like image 370
Raymond.Reddington Avatar asked Feb 28 '26 09:02

Raymond.Reddington


1 Answers

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.

like image 121
Diodacus Avatar answered Mar 03 '26 07:03

Diodacus