/id

:suspect: ID, a compile-time string hasher and sequential ID generator (C++11)

Primary LanguageC++zlib LicenseZlib

id

ID, a compile-time string hasher and sequential ID generator (C++11).

Features

  • Based on code by Stefan 'Tivolo' Reinalter.
  • Tiny, header-only, cross-platform.
  • No dependencies.
  • ZLIB/LibPNG licensed.

Cons

  • Modern C++11 compiler required, or optimizations enabled at least.

Sample

#include <iostream>
#include "id.hpp"

int main() {
    // generate compile-time hash ids
    std::cout << $id("HELLO_WORLD") << std::endl;
    std::cout << $id("PLAYER_1") << std::endl;

    // generate sequential ids
    std::cout << $id() << std::endl;
    std::cout << $id() << std::endl;

    // resetting sequential generator is allowed
    $id() = 0;
    std::cout << $id() << std::endl;
}

Changelog

  • v1.0.0 (2015/10/01)
    • Semantic versioning adherence