Demo entry 6757334

Defining Event Types

   

Submitted by anonymous on Aug 08, 2018 at 23:26
Language: C++. Code size: 421 Bytes.

struct MyArgs {
    int id;
    double price;
};

template <typename EventT>
struct MyTrackerAccessor {
public:
    typename EventT::TrackerType *operator()(const typename EventT::EventArgsType &args) {
        return &m[args.id];
    }

private:
    std::unordered_map<int, typename EventT::TrackerType> m;
};

struct IPublisher { };

using MyEvent = EventCutter<MyArgs, IPublisher, MyTrackerAccessor>;

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).