lundi 9 mai 2022

Is it possible to check if some type doesn't exist in a parameter pack

I'm working on a C++14 project and I just wrote a function with parameter pack.

template <typename... Args>
void func(Args&&... args) {
    ...
}

The args should contain only int or std::string, it can't be any other types.

Is there any way to do the check at compile time? Maybe something as below?

template <typename... Args, std::enable_if_t<???* = nullptr>
void func(Args&&... args) {
    ...
}

Aucun commentaire:

Enregistrer un commentaire