VS2005 Compiler bug

  • Thread starter Thread starter Staffan Langin
  • Start date Start date
S

Staffan Langin

Hello,

Is there a workaround for the code-snippet below?


namespace A {
template<class T>
class Foo
{
};
}

template<class T>
class Foo : public A::Foo<T>
{
friend class A::Foo<T>;
};
 
Staffan said:
Hello,

Is there a workaround for the code-snippet below?


namespace A {
template<class T>
class Foo
{
};
}

template<class T>
class Foo : public A::Foo<T>
{
friend class A::Foo<T>;
};

This works in VS2003 (at least it compiles):

template<class T>
class Foo : public A::Foo<T>
{
typedef A::Foo<T> AFoo;
friend class Afoo;
};

David Wilkinson
 
Staffan Langin said:
Is there a workaround for the code-snippet below?
VC is known to have issue with templates and friends.
namespace A {
template<class T>
class Foo
{
};
}

template<class T>
class Foo : public A::Foo<T>
{
friend class A::Foo<T>;

I've seen VC treat class X in a friend declaration as
a ETS introducing a new type in the innermost containing
namespace scope.

You could try to omit class and it should work for VC++
(but not for other compilers)

-hg
 
You could try to omit class and it should work for VC++
(but not for other compilers)


Yes, that seems to work for VS2005. Thanks.

Best regards,

Staffan Langin
 
This works in VS2003 (at least it compiles):
template<class T>
class Foo : public A::Foo<T>
{
typedef A::Foo<T> AFoo;
friend class Afoo;
};

David Wilkinson

David,

It seems to work with VS2005 aswell. Thanks!

Best regards,

Staffan Langin
 
Back
Top