While trying to answer one question here, I found this question:
How to recursively dereference pointer (C++03)?
Adapted code from the answer is following:>
You can do it with a trait to compute the ultimate return type, here dubbed remove_all_pointers
:
#include
template struct remove_all_pointers
{ typedef typename std::remove_reference::type type; };
template struct remove_all_pointers
{ typedef typename std::remove_reference::type type; };
template
T & dereference(T & p)
{ return p; }
template
typename remove_all_pointers::type & dereference(U * p)
{ return dereference(*p); }
int main(int argc, char * argv[])
{
return dereference(argv);
}
You may need to add CV-variants; I'm still thinking about that.