Skip to content

Instantly share code, notes, and snippets.

@janderudder
Last active March 11, 2019 18:31
Show Gist options
  • Save janderudder/982913713d59403e7b907676e508732c to your computer and use it in GitHub Desktop.
Save janderudder/982913713d59403e7b907676e508732c to your computer and use it in GitHub Desktop.
Get a unique numeric identifier for a type, without RTTI.
#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