I would expect the last two lines of thisthe first code printingexample to print the same, i.e.
The types are deducted as I expect and the word "template"the overload resolution is also as I expect. ObviouslyHowever, if I explicitly type qualify the function call, then I get a different result then when the type deduction works correctly everywhereis deduced.
But if I type qualifyThe second code example repeats the called functionexercise replacing overload itresolution with specialization. In that case everything works in all cases except where the template argument is itself a templateas anyone would expect.
EDITCode Example 1: Added further overload with two type parameters to make things clearer for myself. Now it is clear to me that print<R, int>(r) has one single template argument and not two just as in template<template<class> class R, class T>. (1) and (2function template overloading) must either render the same or one of them must be an error. Anybody who thinks all compilers are doing correct would surely agree this is at least worth a compiler warning with -pedantic option.
When I replace function overloading withCode Example 2: (class template specialization, then template pattern matching works as I would have expected. See next code example. I have some trouble believing that the pattern matching rules also differ between classes and functions. If that is really true then I would say that Walter is right when he says, avoid it).