Last active
March 11, 2019 18:31
-
-
Save janderudder/982913713d59403e7b907676e508732c to your computer and use it in GitHub Desktop.
Get a unique numeric identifier for a type, without RTTI.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <cstdint> | |
#include <type_traits> | |
using TypeUniqueId = std::uintptr_t; | |
template <typename T> | |
constexpr TypeUniqueId typeUniqueId() | |
{ | |
return reinterpret_cast<TypeUniqueId>(&typeUniqueId<T>); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment