delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/05/21/10:43:12

From: glier AT stud DOT uni-frankfurt DOT de (Oliver Glier)
Subject: problem with inner classes in template functions
21 May 1997 10:43:12 -0700 :
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <3382BFCB.89F0591C.cygnus.gnu-win32@stud.uni-frankfurt.de>
Mime-Version: 1.0
X-Mailer: Mozilla 4.0b4 [en] (Win95; I)
Original-To: gnu-win32 AT cygnus DOT com
X-Priority: 3 (Normal)
Original-Sender: owner-gnu-win32 AT cygnus DOT com

Dear peoply from the GNU-WIN32 project,
my name is Oliver Glier and I'm porting a C++ class library to
Windows. The code is already compilable by Borland C++,
Sun Sparc C++, and GCC 2.7 (EMX , Linux, and Sun).
My problem is that I would like to use your compiler (beta 1.8) ,
but it  doesn't accept the following construct:

template<class T>
class Container
{
public:
  class Iterator {
    public:
      void setnull();
  };
};

template<class C>
void createIterator(const C&)
{
  C::Iterator it;
  it.setnull();
}

void test()
{
  Container<int> numbers;
  createIterator(numbers);
}

The compiler always yields a syntax error at the line with
"C::Iterator it;" in function createIterator(). The funny thing is
that the compiler rejects the code before createIterator(
Container<int>) is generated, that is, while createIterator()
is nothing more than a raw template. Still, I think that
code as above is correct C++. At least it works with a lot
of other C++ compilers and seems to be important in the
use of class libraries such as STL.

Last but not least I must say that I'm very grateful for your
efforts of porting GNU C++ to Windows. You project is
great and I hope the best for its future.

With best regards,
Oliver.

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019