c++ - Make a templated structure to turn a pointer with any count of * to work as a & -


i've encountered thing got me thinking... perhaps utter newbie question ask wanted achieve template work like:

forwardedreference<int****> x(somepointerwithfourstars); int& y = x.ref; 

but don't want runtime recurrent function calls. tried make partially specified structure templates, no success yet (i still try achieve goal).

my initial idea have 2 types of templates a<t> , b<t, u> alter 1 another. specialization of first 1 t*, , other 1 t*, t.

i thought a<t*> having field of b<t*, t>, , b<t*, t> having a<t> instance.

i have failed on compilation errors, , can't dig right (though later), because i'm @ work t_t i'm eager answer if possible do, , how. don't know if use in nearest future, expand knowledge stuff that.

if feel there not enough details, please let me know - @ thread time time.

but don't want runtime recurrent function calls

tough shit. can define type int& int**** relatively tmp, cannot access without using recursion, because type of each intermediate stage different , don't know how many intermediate stages there are. have use recursion de-reference pointer.


Comments