Event Messenger C++ Game Programming I'm using this Game Messenger as an instant messaging tool in my game. Just wondering peoples on thoughts on it.
Thank you!
    enum class eGameMessageType
{
    AddItemGUI = 0,
    RemoveItemGUI,
    UpdateSelectionBoxGUI,
    UpdateItemQuantityGUI,
    DestroyCubeSetPosition, 
    DestroyCubeReset,
    SelectedCubeSetPosition,
    SelectedCubeSetActive,
    SpawnPickup,
    PlayerDisgardPickup,
    AddToPlayerInventory,
    Max = AddToPlayerInventory
};

struct Listener : private NonCopyable
{
    Listener(const std::function&lt;void(const void*)&gt;&amp; fp, const void* ownerAddress)
        : m_listener(fp),
        m_ownerAddress(ownerAddress)
    {
        assert(ownerAddress);
    }
    Listener(Listener&amp;&amp; rhs) noexcept
        : m_listener(rhs.m_listener),
        m_ownerAddress(rhs.m_ownerAddress)
    {
        rhs.m_listener = nullptr;
        rhs.m_ownerAddress = nullptr;
    }
    Listener&amp; operator=(Listener&amp;&amp; rhs) noexcept
    {
        m_listener = rhs.m_listener;
        m_ownerAddress = rhs.m_ownerAddress;

        rhs.m_listener = nullptr;
        rhs.m_ownerAddress = nullptr;

        return *this;
    }

    std::function&lt;void(const void*)&gt; m_listener;
    const void* m_ownerAddress;
};

class GameMessenger : private NonCopyable, private NonMovable 
{
public:
    static GameMessenger&amp; getInstance()
    {
        static GameMessenger instance;
        return instance;
    }

    template &lt;typename GameMessage&gt;
    void subscribe(const std::function&lt;void(const GameMessage&amp;)&gt;&amp; gameMessage, const void* ownerAddress)
    {
        auto&amp; listeners = m_listeners[static_cast&lt;int&gt;(GameMessage::getType())];
        assert(!isOwnerAlreadyRegistered(listeners, GameMessage::getType(), ownerAddress));

        listeners.emplace_back(reinterpret_cast&lt;std::function&lt;void(const void*)&gt; const&amp;&gt;(gameMessage), ownerAddress);
    }

    template &lt;typename GameMessage&gt;
    void unsubscribe(const void* ownerAddress)
    {
        auto&amp; listeners = m_listeners[static_cast&lt;int&gt;(GameMessage::getType())];
        assert(isOwnerAlreadyRegistered(listeners, GameMessage::getType(), ownerAddress));

        auto iter = std::find_if(listeners.begin(), listeners.end(), [ownerAddress](const auto&amp; listener)
        {
            return listener.m_ownerAddress == ownerAddress;
        });

        assert(iter != listeners.end());
        listeners.erase(iter);
    }

    template &lt;typename GameMessage&gt;
    void broadcast(GameMessage gameMessage)
    {
        const auto&amp; listeners = m_listeners[static_cast&lt;int&gt;(GameMessage::getType())];
        for (const auto&amp; listener : listeners)
        {
            reinterpret_cast&lt;std::function&lt;void(const GameMessage&amp;)&gt; const&amp;&gt;(listener.m_listener)(gameMessage);
        }
    }

private:
    GameMessenger() {}
    std::array&lt;std::vector&lt;Listener&gt;, static_cast&lt;size_t&gt;(eGameMessageType::Max) + 1&gt; m_listeners;

    bool isOwnerAlreadyRegistered(const std::vector&lt;Listener&gt;&amp; listeners, eGameMessageType gameMessageType, const void* ownerAddress) const
    {
        assert(ownerAddress != nullptr);

        if (!listeners.empty())
        {
            auto result = std::find_if(listeners.cbegin(), listeners.cend(), [ownerAddress](const auto&amp; listener)
            {
                return listener.m_ownerAddress == ownerAddress;
            });

            return result != listeners.cend();
        }
        else
        {
            return false;
        }
    }
};
Move struct Listener into class GameMessenger
The struct Listener is just an implementation detail of GameMessenger, you can move it into class GameMessenger like so:
class GameMessenger: ...
{
    struct Listener: ...
    {
         ...
    };

    ...
};

Now that it is private, I would also keep Listener very simple, and just have it hold the two member variables, without adding any member functions.
Pass messages as const references
The actual message handler functions take a const reference to the message, but your GameMessenger::broadcast() takes it by value, making an unnecessary copy. Change it to:
void broadcast(const GameMessage &amp;gameMessage) {...}

Naming things
Some names could be improved. For example, struct Listener has a member variable m_listener. Combined with the std::vector&lt;Listener&gt;, you get the word listener repeated a lot, like in GameMessenger::broadcast(), where there's even a listener.m_listener. Consider renaming m_listener to m_handler or m_callback.
Some names are a bit longer than necessary. I suggest these changes:
- `typename GameMessage` -&gt; `typename Message`
- `isOwnerAlreadyRegistered()` -&gt; `isRegistered()`

Make class GameMessenger a template
With void pointers you throw type-safety overboard, and requires you to reinterpret_cast&lt;&gt;() things. I can't say much about m_ownerAddress, however
the main problem here is that you have a non-templated class GameMessenger. Apart from the constructor, all the public member functions are template &lt;typename GameMessage&gt;. Instead of having one GameMessenger object being responsible for all possible message types, consider making the class templated itself, and only be responsible for one specific message type.
If you implement it this way, there will be one GameMessenger object per message type. That means there is no longer a need to have a std::array for each of the possible message types, and in fact enum eGameMessageType is no longer necessary.
Here is an example of how it might look:
template &lt;typename Message&gt;
class GameMessenger: private NonCopyable, private NonMovable 
{
    struct Listener {
        const std::function&lt;void(const Message &amp;)&gt; m_handler;
        const void *m_ownerAddress;
    };

public:
    static GameMessenger&amp; getInstance()
    {
        static GameMessenger instance;
        return instance;
    }

    void subscribe(const std::function&lt;void(const Message&amp;)&gt;&amp; handler, const void* ownerAddress)
    {
        assert(!isRegistered(ownerAddress));
        listeners.emplace_back(handler, ownerAddress);
    }

    template &lt;typename Message&gt;
    void unsubscribe(const void* ownerAddress)
    {
        auto iter = std::find_if(m_listeners.begin(), m_listeners.end(), [ownerAddress](const auto&amp; listener)
        {
            return listener.m_ownerAddress == ownerAddress;
        });

        assert(iter != listeners.end());
        listeners.erase(iter);
    }

    void broadcast(const Message &amp;message)
    {
        for (const auto&amp; listener: m_listeners)
        {
            listener.m_handler(message);
        }
    }

private:
    std::vector&lt;Listener&gt; m_listeners;

    bool isRegistered(const void* ownerAddress) const
    {
        assert(ownerAddress != nullptr);

        auto result = std::find_if(listeners.cbegin(), listeners.cend(), [ownerAddress](const auto&amp; listener)
        {
            return listener.m_ownerAddress == ownerAddress;
        });

        return result != listeners.cend();
    }
};

So how do you use it? Instead of writing:
void handleSpawnPickup(const SpawnPickupMessage &amp;message) {...}
void *ownerAddress = ...;

auto messenger = GameMessenger.getInstance();
messenger.subscribe(handleSpawnPickup, ownerAddress);

You replace the last two lines with:
auto messenger = GameMessenger&lt;SpawnPickupMessage&gt;.getInstance();
messenger.subscribe(handleSpawnPickup, ownerAddress);

If you want to avoid having to explicitly mention the type when getting the messenger instance, consider writing an out-of-class function that subscribes to the right instance for you:
template&lt;typename Message&gt;
void subscribeToMessenger(const std::function&lt;void(const Message&amp;)&gt;&amp; handler, const void* ownerAddress)
{
    GameMessenger&lt;Message&gt;::getInstance().subscribe(handler, ownerAddress);
}

So that you can just write:
subscribeToMessenger(handleSpawnPickup, ownerAddress);