3

I am trying to implement a class that takes a number of events and then returns the first event that becomes active.

The class is something like

template <typename ...Event>
class OneOf {
public:
    OneOf(Event... events);
    std::variant<Event...> getReturn();
private:
    std::tuple<Event...> m_events;
};

The problem is that the template may take duplicates of the same type for the event but the std::variant will only accept unique event types.

How do I define the std::variant in such a way so that all duplicate types from my parameter pack are eliminated?

JFMR
  • 23,265
  • 4
  • 52
  • 76
doron
  • 27,972
  • 12
  • 65
  • 103
  • [here](https://stackoverflow.com/questions/13827319/eliminate-duplicate-entries-from-c11-variadic-template-arguments) is a C++11 solution. I would think it could be shortened using C++17 and fold expressions. – NathanOliver Aug 16 '19 at 16:01

0 Answers0