The substitution and deduction is not lexically like with a macro. volatile T*
will not become volatile Node**
but volatile Node* volatile*
. The second volatile comes from the template. That makes T equal volatile Node*
for the first parameter.
Try to free yourself from sticking the volatile always at the beginning, but put it qhere it belongs according to the actual type. A volatile pointer has the volatile after the star, not before it.