summaryrefslogtreecommitdiff
path: root/include/mbgl/util/typeid.hpp
blob: 4161b994894b6e7b9913e02148eaf0df65e79edf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#pragma once

#include <atomic>

namespace mbgl {
namespace util {

class TypeID {
public:
    template <typename T>
    static uint32_t getID() {
        static std::atomic<uint32_t> count(increment());
        return count;
    }

private:
    static uint32_t increment() {
        static std::atomic<uint32_t> count(0);
        return count++;
    }

};

} // namespace util
} // namespace mbgl