mercredi 20 mars 2019

Check if parent constructor has parameters

I have got this code:

template<class T>
class StackException: public T {
    public:
        StackException(const char* msg): T(msg) {} //<---problem here
}

template<class T>
void myThrow(const &T e) {
    throw StackException<T>(e.what());
}

This code works for generic exceptions with a what method, but sometimes the exception in my code are defined without any parameter in the constructor. I need a way to enable/disable the constructor of StackException according to the parent constructor. How can I do that with SFINAE? I'm using c++11.

Aucun commentaire:

Enregistrer un commentaire