mardi 18 septembre 2018

How to check if given class is included inside parameter pack [duplicate]

This question already has an answer here:

Given:

class foo_t { };

template<class ... args_t> class bar_t
{
    static_assert(/*fire if foo_t is not part of args_t*/);
};

bar_t<foo_t, int, std::string> bar1; // ok
bar_t<char> bar2; // triggers static_assert above

How one can implement a static_assert in question?

Aucun commentaire:

Enregistrer un commentaire