www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - Namespace test-cases

↑ ↓ ← 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
↑ ↓ 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
↑ ↓ 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
↑ ↓ → "Walter" <walter digitalmars.com> writes:
Thanks, I'll take care of them. -Walter
Dec 03 2002