mercredi 24 mai 2017

Static Assert for Public Inheritance

I built a helper class that would construct a custom class via templates, this custom class must inherit from a certain class, I can check for this with std::is_base_of.

However I also need to check that the inheritance is public, how can this be achieved?

For reference, here is a stripped down version of the class, I have the std::is_base_of in there.

template<class CustomSink>
class Sink
{
    static_assert(std::is_base_of<BaseSink, CustomSink>::value, "CustomSink must derive from BaseSink");
    //Some static assert here to check if custom sink has publicly inherited BaseSink 
    //static_assert(is_public.....
public:
    template<class... Args>
    Sink(Args&&... args)
    {
    }
    ~Sink()
    {
    }       
};

Aucun commentaire:

Enregistrer un commentaire