c++ - Namespace test-cases
- Christof Meerwald (63/63) Dec 03 2002 I am not sure if I have already reported these (at least they still don'...
- Christof Meerwald (26/26) Dec 03 2002 Another one:
- Christof Meerwald (29/29) Dec 03 2002 Here is another one:
- Walter (1/1) Dec 03 2002 Thanks, I'll take care of them. -Walter
I am not sure if I have already reported these (at least they still don't
work with DMC 8.32.4):
// ----------------------------------------
template <class T>
struct A
{ };
struct B
{
template <class T> B(A<T> &a)
{ }
};
struct C
{
template <class T> C(::A<T> &a)
{ }
// Error: malformed template declaration
};
// ----------------------------------------
namespace ns
{
class A
{ };
}
class B
{
friend class ns::A;
// Error: only classes and functions can be friends
};
// ----------------------------------------
namespace N
{
template<class T> void f(T a)
{ }
template<class T> void g(T a)
{
f(a);
// Error: function 'f' has no prototype
}
}
int main(int argc, char *argv[])
{
N::g(3);
return 0;
}
// ----------------------------------------
namespace ns
{
template<class T> void f(T a)
{ }
}
using ns::f;
int main()
{
int a = 0;
f(a);
// Error: illegal cast
return 0;
}
bye, Christof
--
http://cmeerw.org JID: cmeerw jabber.at
mailto cmeerw at web.de
...and what have you contributed to the Net?
Dec 03 2002
Another one:
namespace ns
{
struct B
{ };
template<class T>
struct A
{
template<class U>
void f(U x, ns::B /* works if some identifier is added here */)
{ }
// Error: 'f' is not a class template
};
}
int main()
{
ns::A<int> a;
ns::B b;
a.f(1, b);
return 0;
}
bye, Christof
--
http://cmeerw.org JID: cmeerw jabber.at
mailto cmeerw at web.de
...and what have you contributed to the Net?
Dec 03 2002
Here is another one:
namespace ns
{
template<class T>
struct A
{ };
template<class T>
struct B
{
template<class U>
void f(U u)
{
A<U> a;
// Error: undefined identifier 'A'
// it works if I use ns::A<U> instead
}
};
}
int main()
{
ns::B<int> b;
b.f(1);
return 0;
}
bye, Christof
--
http://cmeerw.org JID: cmeerw jabber.at
mailto cmeerw at web.de
...and what have you contributed to the Net?
Dec 03 2002








"Walter" <walter digitalmars.com>