vendredi 22 février 2019

Disable constructor for non-const instances

I have a simple class and I'm hoping to keep it simple. The only wrinkle is that I want to conditionally disable a constructor for non-const instances.

I'd like to do something like:

struct X {
    template<typename = std::enable_if_t<std::is_const<this>::value>>
    X(...) {
        ....
    }
};

However, that doesn't work for several reasons. Is there a way to do something along those lines?

Aucun commentaire:

Enregistrer un commentaire