Not sure if that's what you want but maybe it helps:
import std/macrocache
const nextTypeId = CacheCounter("nextTypeId")
type TypeId = int
func typeId*(T:typedesc): TypeId =
const id = nextTypeId.value
static:
inc nextTypeId
id
echo typeId(int)
echo typeId(string)
echo typeId(float)
echo typeId(int)
Run
- Unique ID's for types? elcritch
- Unique ID's for types? Hlaaftana
- Unique ID's for types? shirleyquirk
- Unique ID's for types? tsojtsoj
- Unique ID's for types? elcritch
