www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/08/14/21:30:31

Xref: news2.mv.net comp.os.msdos.djgpp:7280
From: edkiser AT jaxnet DOT com (M. Edward Kiser)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Standard C++ Library? I give up!
Date: Tue, 13 Aug 1996 06:33:40 GMT
Organization: Southeast Network Services, Inc.
Lines: 76
Message-ID: <4up82j$llj@jaxnet.southeast.net>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 960808092734 DOT 19168J-100000 AT is>
Reply-To: edkiser AT jaxnet DOT com
NNTP-Posting-Host: ts2-006.southeast.net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> wrote:

>On Tue, 6 Aug 1996, M. Edward Kiser wrote:

>> complexu.cpp: In function `int main()':
>> complexu.cpp:22: redeclaration of `class complex<float> * ii'
>> complexu.cpp:22: `class complex<float> * ii' previously declared here

>Did you read section 8.11 of the DJGPP FAQ list?  It discusses some
>possible problems with using class complex in DJGPP.  The latest version
>of the FAQ is available as v2/faq201b.zip from the same place you get
>DJGPP. 

I _had_ read the FAQ 2.00 and found nothing. I didn't know 2.01 was
out until I saw your message. Thanks.

But it didn't help. I'm _not_ confusing the GNU Complex class with the
complex<> template. That seems to be what the FAQ's talking about.

Maybe I should have numbered my lines, it's not even clear to me where
the error is... the problem seems to be coming from the "vec::iterator
ii" inside the "for" parentheses. It should expand to "complex<float>
* ii". It seems not to be working. That's STL, not the complex<>
template.

I've had problems with templates before.

It seems under GCC that:

* A template can't have a static data member. This is too bad because
the STL list<> likes to keep a free list in a static buffer. This, of
course, means EACH instantiation of the template would have its own
buffer. Right now that code is inside #if 0 ... #endif, so I guess GCC
doesn't support it.

* A template _can_ have an enum or a typedef inside it, but this enum
or typedef is only usable inside the class declaration. This is too
bad, because vector<>::iterator, vector<>::const_iterator, and so
forth are all typedefs; you can see for yourself in the .H file. Maybe
this is the problem that I'm having with vec::iterator.

I tried to write a hybrid array-stack with an enum mode
{ absolute, relative }, but when I had a function

template <typename T>
T arraystack<T>::peek
(arraystack<T>::index i,
 arraystack<T>::mode m = arraystack<T>::relative
);

the compiler couldn't find

arraystack<T>::index

because it said arraystack<T> was an incomplete type.
"arraystack::index" did the same thing, and "index" alone, of course,
was undefined. But I was desperate and had to try it.

You can put those enums and typedefs in a parent class and make the
template descend from that class, but STL's typedefs are parametric,
so that won't work.

I've had other problems with STL: it has some templates in it so that
if the operators != <= > >= aren't defined, it defines them (as
template functions) in terms of == and < for you. But then when
CINST.H tries to instantiate one of the != operators for complex<>,
GCC says the instantiation is ambiguous. So I can't use STL and
complex<> in the same program?

Without these standard classes, C++ itself is broken.

--------
Ed Kiser (edkiser AT jaxnet DOT com)
"The great epochs of our lives are at the points where
 we rebaptize our badness as the best in us." -- Nietzsche

- Raw text -


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