I want to make a function publicly available in a derived class, only when the calling parameter has a special tag. I'm using C++14 with Clang.
Giveǹ is the following situation:
struct TagA {};
struct TagB {};
struct Base {
protected:
void handler(const std::shared_ptr<Base> &obj) {
...
}
};
The goal is to make handler
available in derived classes, if they have a special tag, to allow different "classes" of derived objects. Like this:
struct DerivedA : Base, TagA {
// This should only be available, if the obj argument for handler
// derives from TagA
// something like std::enable_if<std::is_base_of<TagA, ???>::value>
using Base::handler;
};
This would allow DerivedA
to handle
struct HandledA : Base, TagA {
};
but not
struct UnhandledA : Base, TagB {
};
although UnhandledA
inherits from Base
and handler
only needs Base
.