I've got a templated class having two template paramters

```
template <class T, class U> class A  /* ... */

```

and another template class that accepts a template class with two arguments as template parameter.

```
template <class T, class U, template<class X, class Y> class Z>
class B
{
    typedef typename Z<T,U>::pointer pointer;
};

```

Is it impossible to create an instance of B in A where Z is A?

```
template <class T, class U>
class A  
{
public:
  B<T,U,A> foo (void) // compiler complaining here
  {
    B<T,U,A> test; // and here
    return test;
  }
};

```

A free function doing the same thing isn't problematic at all.

```
template<class T, class U>
B<T, U, A> bar (void)
{
    B<T,U,A> test;
    return test;
}

```

In other words: Is there any rule I didn't fell over yet that prevents me from using the name of the class I am in as a template argument?

---

The code is:

```
template <class T, class U, template<class X, class Y> class Z>
class B
{
  typedef typename Z<T,U>::pointer pointer;
};

template <class T, class U>
class A 
{
public:
  B<T,U, A> foo (void) 
  {
    B<T,U,A> test;
    return test;
  }
};

template<class T, class U>
B<T, U, A> bar (void)
{
    B<T,U,A> test;
    return test;
}

int main (void)
{
 return 0;
}

```

And the MSVC 2012 compiler gives a [Compiler Error 3200](http://msdn.microsoft.com/en-us/library/3xwxftta.aspx).

```
'A<T,U>' : invalid template argument for template parameter 'Z', expected a class template

```