public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ templates
@ 2003-01-12  9:05 erwan ancel
  2003-01-12 10:25 ` C++ templates: precisions erwan ancel
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: erwan ancel @ 2003-01-12  9:05 UTC (permalink / raw)
  To: gcc-help

Hi,
Does anybody know where I can find a detailed description on templates
syntax in C++ ?

    Thanks.


                Erwan


^ permalink raw reply	[flat|nested] 7+ messages in thread

* C++ templates: precisions
  2003-01-12  9:05 C++ templates erwan ancel
@ 2003-01-12 10:25 ` erwan ancel
  2003-01-12 11:05   ` Sebastian Huber
  2003-01-12 13:27   ` LLeweLLyn Reese
  2003-01-13  9:10 ` C++ templates Fabio Mazzone
  2003-01-13 13:22 ` Oliver Kullmann
  2 siblings, 2 replies; 7+ messages in thread
From: erwan ancel @ 2003-01-12 10:25 UTC (permalink / raw)
  To: gcc-help

well, this is my problem:

I would like to make a template class that owns a set of elements that have
the type of one of the class parameters. And it doesn't compile...
example:

#include <set>
template <class T>
class A
{
    public:
        A();
        B();
        std::set<T> _list;
};

the compiler's output tells that the type T is not defined... Well, of
course, but it will be defined when the template will be instanciated. So it
should be possible...
Does anybody know a solution to my problem?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: C++ templates: precisions
  2003-01-12 10:25 ` C++ templates: precisions erwan ancel
@ 2003-01-12 11:05   ` Sebastian Huber
  2003-01-12 11:25     ` erwan ancel
  2003-01-12 13:27   ` LLeweLLyn Reese
  1 sibling, 1 reply; 7+ messages in thread
From: Sebastian Huber @ 2003-01-12 11:05 UTC (permalink / raw)
  To: gcc-help

Hello!

On Sunday 12 January 2003 11:25, erwan ancel wrote:
> well, this is my problem:
>
> I would like to make a template class that owns a set of elements that have
> the type of one of the class parameters. And it doesn't compile...
> example:
>
> #include <set>
> template <class T>

'template<typename T>' may fix your problem.

> class A
> {
>     public:
>         A();
>         B();
>         std::set<T> _list;
> };
>
> the compiler's output tells that the type T is not defined... Well, of
> course, but it will be defined when the template will be instanciated. So
> it should be possible...
> Does anybody know a solution to my problem?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: C++ templates: precisions
  2003-01-12 11:05   ` Sebastian Huber
@ 2003-01-12 11:25     ` erwan ancel
  0 siblings, 0 replies; 7+ messages in thread
From: erwan ancel @ 2003-01-12 11:25 UTC (permalink / raw)
  To: gcc-help


Yes, you're right. But why is it ??
Does the compiler go further to 'cache' a pre-compilation of the template in
case of class ?

----- Original Message -----
From: "Sebastian Huber" <sebastian-huber@web.de>
To: <gcc-help@gcc.gnu.org>
Sent: Sunday, January 12, 2003 12:02 PM
Subject: Re: C++ templates: precisions


Hello!

On Sunday 12 January 2003 11:25, erwan ancel wrote:
> well, this is my problem:
>
> I would like to make a template class that owns a set of elements that
have
> the type of one of the class parameters. And it doesn't compile...
> example:
>
> #include <set>
> template <class T>

'template<typename T>' may fix your problem.

> class A
> {
>     public:
>         A();
>         B();
>         std::set<T> _list;
> };
>
> the compiler's output tells that the type T is not defined... Well, of
> course, but it will be defined when the template will be instanciated. So
> it should be possible...
> Does anybody know a solution to my problem?


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: C++ templates: precisions
  2003-01-12 10:25 ` C++ templates: precisions erwan ancel
  2003-01-12 11:05   ` Sebastian Huber
@ 2003-01-12 13:27   ` LLeweLLyn Reese
  1 sibling, 0 replies; 7+ messages in thread
From: LLeweLLyn Reese @ 2003-01-12 13:27 UTC (permalink / raw)
  To: erwan ancel; +Cc: gcc-help

"erwan ancel" <erwan.ancel@free.fr> writes:

> well, this is my problem:
> 
> I would like to make a template class that owns a set of elements that have
> the type of one of the class parameters. And it doesn't compile...
> example:
> 
> #include <set>
> template <class T>
> class A
> {
>     public:
>         A();
>         B();

set_t.cc:7: ISO C++ forbids declaration of `B' with no type

That's the only error I get for your code. Take a 'B()' and it disappears.

>         std::set<T> _list;
> };
> 
> the compiler's output tells that the type T is not defined... Well,
> of

I get no such error message. I tried with gcc 2.95.3, and gcc 3.2.1 .

> course, but it will be defined when the template will be instanciated. So it
> should be possible...
> Does anybody know a solution to my problem?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: C++ templates
  2003-01-12  9:05 C++ templates erwan ancel
  2003-01-12 10:25 ` C++ templates: precisions erwan ancel
@ 2003-01-13  9:10 ` Fabio Mazzone
  2003-01-13 13:22 ` Oliver Kullmann
  2 siblings, 0 replies; 7+ messages in thread
From: Fabio Mazzone @ 2003-01-13  9:10 UTC (permalink / raw)
  To: erwan ancel, gcc-help

i suggest you to buy:
bjarne stroustrap's  "the c++ programming language" 
that created such a language.
Other case try to look on the net (google....).
have fun!
                       fa

----- Original Message ----- 
From: "erwan ancel" <erwan.ancel@free.fr>
To: <gcc-help@gcc.gnu.org>
Sent: Sunday, January 12, 2003 10:05 AM
Subject: C++ templates


> Hi,
> Does anybody know where I can find a detailed description on templates
> syntax in C++ ?
> 
>     Thanks.
> 
> 
>                 Erwan
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: C++ templates
  2003-01-12  9:05 C++ templates erwan ancel
  2003-01-12 10:25 ` C++ templates: precisions erwan ancel
  2003-01-13  9:10 ` C++ templates Fabio Mazzone
@ 2003-01-13 13:22 ` Oliver Kullmann
  2 siblings, 0 replies; 7+ messages in thread
From: Oliver Kullmann @ 2003-01-13 13:22 UTC (permalink / raw)
  To: gcc-help

> Hi,
> Does anybody know where I can find a detailed description on templates
> syntax in C++ ?
> 
>     Thanks.
> 
> 
>                 Erwan
> 

The best you can find specifically on templates is

@Book{JV2002,
  author =	 {David Vandevoorde and Nicolai M. Josuttis},
  title = 	 {C++ Templates: The Complete Guide},
  publisher = 	 {Addison-Wesley},
  year = 	 2002,
  address =	 {Boston},
  month =	 {November},
  note =	 {ISBN 0-201-73484-2; QA76.73.C153 V37 2003},
  annote =	 {Vorhanden.}
}

also a very important source for generic programming is

@Book{CE2000,
  author =	 {Krzysztof Czarnecki and Ulrich W. Eisenecker},
  title = 	 {Generative Programming},
  publisher = 	 {Addison Wesley},
  year = 	 2000,
  address =	 {Boston},
  note =	 {ISBN 0-201-30977-7; QA76.624.C93 2000},
  annote =	 {Vorhanden.}
}

(covering a much broader range); and finally a lot of interesting material
is contained in

@Book{Al2001,
  author =	 {Andrei Alexandrescu},
  title = 	 {Modern C++ Design},
  publisher = 	 {Addison-Wesley},
  year = 	 2001,
  series =	 {The C++ In-Depth Series},
  address =	 {Boston},
  month =	 {June},
  note =	 {ISBN 0-201-70431-5, QA76.73.C153 A42 2001},
  annote =	 {Vorhanden.}
}

Oliver

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-01-13 13:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-12  9:05 C++ templates erwan ancel
2003-01-12 10:25 ` C++ templates: precisions erwan ancel
2003-01-12 11:05   ` Sebastian Huber
2003-01-12 11:25     ` erwan ancel
2003-01-12 13:27   ` LLeweLLyn Reese
2003-01-13  9:10 ` C++ templates Fabio Mazzone
2003-01-13 13:22 ` Oliver Kullmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).