MOS
id.hpp
1 #pragma once
2 
3 #include <atomic>
4 
5 namespace mos {
6 
7 template<class T>
8 class Id {
9 public:
10  Id() : id(++current_id){}
11  operator int&() { return id; }
12  operator int() const { return id; }
13 private:
14  int id;
15  static std::atomic<int> current_id;
16 };
17 
18 template<class T> std::atomic<int> Id<T>::current_id = 0;
19 
20 }
Definition: id.hpp:8