# Class AnyId reference ## Table Of Contents * [Description](#a2_1) * [API reference](#a2_2) * [Header](#a3_1) * [Class AnyId template parameters](#a3_2) * [Public types](#a3_3) * [Member functions](#a3_4) * [Global type AnyHashableId](#a2_3) * [Comparison AnyId](#a2_4) * [When to use AnyId?](#a2_5) ## Description The template class `AnyId` can be used as the event ID type in `EventDispatcher` and `EventQueue`, then any types can be used as the event type. For example, ```c++ eventpp::EventQueue, void()> eventQueue; eventQueue.appendListener(3, []() {}); // listener 1 eventQueue.appendListener(std::string("hello"), []() {}); // listener 2 eventQueue.dispatch(3); // trigger listener 1 eventQueue.dispatch(std::string("hello")); // trigger listener 2 ``` Note the `eventpp::AnyId<>` in the example code, it's an instantiation of `AnyId` with default template parameters. It's in the place of where an event type should be, such as int. Without `AnyId`, a typical EventQueue looks like, ```c++ eventpp::EventQueue eventQueue; eventQueue.appendListener(3, []() {}); // This doesn't compile because std::string can't be converted to int // eventQueue.appendListener(std::string("hello"), []() {}); ``` For an `int` event type, we can't use `std::string` as the event ID. With `AnyId` in previous example code, we can pass any types as the event ID. ## API reference ### Header eventpp/utilities/anyid.h ### Class AnyId template parameters ```c++ template