www.digitalmars.com         C & C++   DMDScript  

c++ - Namespace test-cases

reply Christof Meerwald <cmeerw web.de> writes:
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
parent reply Christof Meerwald <cmeerw web.de> writes:
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
parent reply Christof Meerwald <cmeerw web.de> writes:
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
parent "Walter" <walter digitalmars.com> writes:
Thanks, I'll take care of them. -Walter
Dec 03 2002