Suppose I have something like:
template
void do_something(T t){
pass_it_somewhere(t);
t->do_something();
}
Now it wo
You could create a dereference mechanism as below:
template
std::enable_if_t::value, std::remove_pointer_t&> dereference(T& t) {
return *t;
}
template
std::enable_if_t::value, T&> dereference(T& t) {
return t;
}
and use it in your function as:
template
void do_something(T t){
pass_it_somewhere(dereference(t));
dereference(t).do_something();
}
Live Demo
This way you'll have to do only with concrete versions of T
.