Although it seems like a simple deduction, what you are wanting the compiler to do would actually be quite complicated and slow to do in general, and it isn't supported by C++.
One way around this is to create another non-nested class that has all the template parameters in one place. You can then make this appear to be a nested class by deriving from it:
template struct A_B {
/* define your class here */
};
template struct A
{
template struct B : A_B {/*nothing here*/};
};
template void test(A_B param) { }
int main()
{
A<1>::B<2> b;
test<1,2>(b); // works
test(b); // works too
}
C++11 also supports template aliasing, which makes this a little cleaner, although it isn't widely supported yet:
template struct A
{
template using B = A_B;
};
This question is closely related:
Workaround for non-deduced context
The answers provided there are useful for your situation as well. If you can make your function be a friend, then you can do this:
template struct A
{
template
struct B
{
};
template
friend void test(B param)
{
}
};