UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » C++
  • » template class compiling

#26 2006-11-30 05:26 PM

HectorLasso
Administrator
From: Colombia
Registered: 2002-06-12
Posts: 353

Re: template class compiling

Offline

#27 2006-12-01 12:30 AM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: template class compiling

Meh, I'm not a real Dutchie, I only live here since my fifth or something, and not in down town, luckily, but in a nice and quiet part further north. There were some lost English tourists around here recently, and they were surprised when I told them they were in Amsterdam already, they had the feeling of being in the middle of nowhere. I don't agree that Amsterdam is that different than the rest of The Netherlands (the stereotypical parts are maybe). For instance, Delft is just a minituarized Amsterdam IMHO, and The Hague is different, but not that different.

I travelled through London on my way to Wales this summer, it looked interesting. It has big parks and hills. Birmingham is such a desolate city. At least the public transport functions in the UK, much better than what we have here (where all the trains in the land stop riding when a network cable is unplugged in Utrecht).

But Eddie Izzard is right, on all accounts. I did get three years of German, four years of French and six years of English at school. It took most of the time, especially French, which was a hell (combination of being bad at languages, a scary teacher and a very bad book we used). Only thing I can say is Je ne parle pas de Francais, and it's the only thing I want to remember. Nothing against German, but can't talk or write it anymore. Without all those languages kids would have time to actually learn something useful at school.

Offline

#28 2006-12-01 12:42 AM

biologz
Administrator
From: Puking on the pavement
Registered: 2005-11-02
Posts: 396

Re: template class compiling

hehe yes french is such an awful language :-) i prefer english. it seems that holland is the opposite of france, here most of the pupils suck in foreign languages, they hardly speak french and i prefer not talking about english...

My only advice to convince them to learn foreign languages (at least english) is that it will make them able to have a lot of women :-) well it worked so well for me that i think they listen to me :-)


gethostbyintuition() is still a dream of mine

                                                 -- quoted from bash

Offline

#29 2006-12-01 08:09 AM

yurec
Member
From: Singapore
Registered: 2006-11-16
Posts: 134

Re: template class compiling

It has,but in windows

Offline

#30 2006-12-10 01:53 AM

mlampkin
Administrator
From: Sol 3
Registered: 2002-06-12
Posts: 911
Website

Re: template class compiling

I realize the conversion has drifted into the nationalities of various members... but a comment on the original question...

Many folks want to seperate out the 'body' of their templates into separate files i.e. *.cpp like a 'regular' class...  while this might seem like a noble pursuit for someone who wants their project file layout to be normalized...

The thing to remember is that the 'body' of a template is NOT REAL CODE but instructions on HOW to generate the final code... that means the compiler, when it sees this, does the equivalent of internally generating the appropriate *.cpp file base on the passed in template type vars and then compiling it... 

So the point is... putting the 'body' of templates into *cpp files... well - really doesn't make much sense when you think about it...


Michael


"The only difference between me and a madman is that I'm not mad."

Salvador Dali (1904-1989)

Offline

#31 2006-12-11 08:35 AM

yurec
Member
From: Singapore
Registered: 2006-11-16
Posts: 134

Re: template class compiling

Anybody inerested in the topic can read the 11-th chapter "c++ templates"of "AIX 5L Porting Guide" by Richard Cutler Allan Cheng Jacob Hsu Jesper F Ljungberg Peter Nutt Michael Perzl ibm/redbooks.

Offline

#32 2006-12-12 08:32 PM

mlampkin
Administrator
From: Sol 3
Registered: 2002-06-12
Posts: 911
Website

Re: template class compiling

I actually just read thru the IBM / AIX compiler doc... interesting information for the AIX compiler way of doing things but...  I did find it strange...

After all...

You should ALWAYS ifdef you headers to prevent multiple inclusions during compilation... this is true not only with CPP template ( headers ) but also normal CPP headers... not to mention C headers...

And... if you are going to be instantiation a template with identical types in multiple files... you should really just be using a ( single ) typedef for it e.g.:

typedef foo<int> fooInt;

then use the fooInt type and the template will be only instantiated once ( in this case as a foo< int > )... you should not constantly keep declaring individual variable of the explicit template instantiation...

So that means if someone does both of these things ( and again - it is normal to do it this way )... then all of their arguments about why the header and implementation should be split into separate files vanish... AND you code is much more likely to work on other compilers - not just theirs...


Michael


"The only difference between me and a madman is that I'm not mad."

Salvador Dali (1904-1989)

Offline

#33 2007-01-20 09:21 AM

yurec
Member
From: Singapore
Registered: 2006-11-16
Posts: 134

Re: template class compiling

i'm a little confused with using extern keyword with templates.I'm not sure i understand it right:when you specialize the template fucntion or class and write "extern" keyword before it the body of a function or constructor will be instantiated once for all futher calls.So the benefit of the usage is a smaller executable file?Is this keyword is used when writing libraries?For the same purposes?And how exaclty?

Offline

#34 2007-01-25 08:56 AM

mlampkin
Administrator
From: Sol 3
Registered: 2002-06-12
Posts: 911
Website

Re: template class compiling

template<typename T> class Foo
{
  void bar( ) { // NOP for example }
};

"The only difference between me and a madman is that I'm not mad."

Salvador Dali (1904-1989)

Offline

  • Index
  • » C++
  • » template class compiling

Board footer

Powered by FluxBB