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<int a,int b> struct A_B {
/* define your class here */
};
template<int a> struct A
{
template<int b> struct B : A_B<a,b> {/*nothing here*/};
};
template<int a, int b> void test(A_B<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<int a> struct A
{
template<int b> using B = A_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<int a> struct A
{
template <int b>
struct B
{
};
template <int b>
friend void test(B<b> param)
{
}
};