mcompiletime_counter.nim 231 B

12345678910111213141516
  1. import std/macros
  2. import std/macrocache
  3. const myCounter = CacheCounter"myCounter"
  4. proc getUniqueId*(): int {.compileTime.} =
  5. inc myCounter
  6. result = myCounter.value
  7. static:
  8. myCounter.inc(3)
  9. assert myCounter.value == 3