Paste Search Dynamic
Recent pastes
GetClock
  1.  
  2. class Example {
  3.  public:
  4.   static void PrintNow() {
  5.     std::cout << GetClock().Now() << std::endl;
  6.   }
  7.    
  8.   static void SetClockForTesting(base::Clock* clock) {
  9.     *GetClockPtr() = clock;
  10.   }
  11.  
  12.  private:
  13.   static base::Clock** GetClockPtr() {
  14.     static base::Clock* clock = new base::DefaultClock();
  15.     return &clock;
  16.   }
  17.  
  18.   static base::Clock& GetClock() {
  19.       return **GetClockPtr();
  20.   }
  21. };
  22.  
Parsed in 0.002 seconds