#exult@irc.freenode.net logs for 31 Jan 2003 (GMT)

Archive Today Yesterday Tomorrow
Exult homepage


[00:34:36] <-- Matt_O has left IRC ("Client Exiting")
[00:34:39] --> Matt_O has joined #exult
[00:55:36] --> Kirben has joined #exult
[00:55:37] --- ChanServ gives channel operator status to Kirben
[01:23:57] --> `daniel has joined #exult
[01:39:59] <-- `daniel has left IRC (adams.freenode.net irc.freenode.net)
[01:39:59] <-- Darke has left IRC (adams.freenode.net irc.freenode.net)
[01:41:13] --> Darke has joined #exult
[01:41:13] --> `daniel has joined #exult
[01:49:53] <-- Darke has left IRC (adams.freenode.net irc.freenode.net)
[01:49:53] <-- `daniel has left IRC (adams.freenode.net irc.freenode.net)
[02:00:58] <-- jerbear has left IRC (Read error: 110 (Connection timed out))
[02:02:07] --> `daniel has joined #exult
[02:21:14] <-- `daniel has left IRC ("Client Exiting")
[03:10:49] <-- Servus has left IRC ()
[04:51:27] --> jerbear has joined #exult
[05:06:26] --> Kirben2 has joined #exult
[05:06:57] <-- Kirben has left IRC (Read error: 104 (Connection reset by peer))
[05:07:11] --> Coren_ has joined #exult
[06:56:18] --> Servus has joined #exult
[07:06:00] * Servus falls over and starts quivering violently
[07:18:07] --> Servus_ has joined #exult
[07:36:45] <-- Servus has left IRC (Read error: 110 (Connection timed out))
[07:40:02] --- Servus_ is now known as Servus
[07:52:47] --> Darke has joined #exult
[07:53:03] --- ChanServ gives channel operator status to Darke
[08:14:43] <Servus> hello
[08:15:22] <Darke> Hi.
[08:16:28] <Servus> whole lotta talking going on
[08:16:43] <Darke> Yep.
[08:17:26] <Servus> Yep.
[08:19:50] --> ShadwChsr has joined #exult
[08:19:54] <ShadwChsr> hey :)
[08:19:56] <Servus> hello
[08:20:30] <ShadwChsr> Weird c++ question
[08:21:08] <ShadwChsr> I want to create a "template" class - however, I don't want to allow it to be templated to *any* type/class. Is there a way I can restrict it to a certain class & it's descendants?
[08:21:47] <Servus> make a virtual abstraction class as your template
[08:22:49] <ShadwChsr> Well what i want is <template SomeClass * T> instead of <template class T>, do you know what I mean?
[08:23:08] <ShadwChsr> I want to at *least* force it to be a pointer, so I can do things like checks against null
[08:24:45] <Darke> If you 'need' it to be a pointer the easiest method is just to test if it's null or not. But that will trip over anything that can be converted to an int (char/ints).
[08:25:52] <Servus> youre dead-set against normal inheritance? or maybe i dont fully understand what templates are as i never ever use them :)
[08:26:24] <ShadwChsr> Since I have control over how the template is used (internal class), I guess it doesn't matter too much :)
[08:27:26] <Servus> it took me a lot of noodling to figure out how to make a class realize teh data in its host-class ( no inheritance involved, class A owns class B which owns class C, and i wanted class C to be able to read class B's data... )
[08:28:05] <ShadwChsr> Usually events ;-)
[08:28:34] <ShadwChsr> In some cases you need to - I toss everything into an object tree and expose the root of the tree (the Game object)
[08:29:17] <Servus> CGame Game:)
[08:30:06] <Servus> i havent done any UW modelling since i finished that Talorid
[08:30:10] <Servus> dunno if anyone wants any more :)
[08:35:52] <ShadwChsr> Gives me errors like "use of undefined type 'T'", "cannot delete objects that are not pointers", etc, etc
[08:35:58] <ShadwChsr> template <class T>
[08:35:58] <ShadwChsr> class ResourceCollection : private vector<T>
[08:36:00] <ShadwChsr> :(
[08:37:11] <Servus> what is the point of using a template? how is it different from normal inheritance?
[08:37:34] <Servus> because there is a way to make a parent superclass that is impossible to instantiate -- its used purely for inheritance
[08:38:08] <ShadwChsr> A template kind of "dynamically changes" a class or function based on the type supplied at it's construction
[08:38:25] <ShadwChsr> Instead of DoSomething(int AnInteger)
[08:38:28] <ShadwChsr> you would have
[08:38:41] <ShadwChsr> template <class T>
[08:38:48] <ShadwChsr> DoSomething(T AnyDataType)
[08:39:21] <ShadwChsr> lets say you wanted to have a vector (list) of integers
[08:39:37] <ShadwChsr> you would declare it as a "vector<int> VectorOfIntegers"
[08:39:54] <ShadwChsr> or you could do "vector<double> VectorOfDoubles"
[08:40:28] <ShadwChsr> hard to explain :) Some people call it "metaprogramming", though I'm not sure why ;)
[08:40:33] <Servus> yes, so how is it different from inheritance:P
[08:40:45] <Servus> i guess ill google it, tho it looks suspiciously like inheritance to me;)
[08:40:48] <ShadwChsr> In inheritence you only know the lowest common demoninator
[08:41:16] <ShadwChsr> How are you going to have a class that provides a collection of integers and a collection of strings?
[08:41:21] <Servus> multiple inheritance is possible, and the final class will let you see and use all inherited parts...
[08:41:28] <Servus> composition:)
[08:41:37] <ShadwChsr> Well, think of it in my case
[08:41:48] <ShadwChsr> I have a resource manager, and the resource manager has collections of resources
[08:42:04] <ShadwChsr> "BaseResource" is the abstract resource class, and based on that I have "Tile", "Actor", etc
[08:42:37] <ShadwChsr> Lets say the resource manager collection class has a function called "BaseResource * GetItem(int Index)"
[08:43:12] <Servus> yep
[08:43:16] <ShadwChsr> straightforward - except I want to do a Tiles.GetItem(0);... it returns a "BaseResource *", which means I need to typecast it "up" the class hierarchy, which isn't really 100% safe
[08:43:35] <ShadwChsr> because what if GetItem returned, say, an Actor pointer instead of a Tile pointer - bam, crash
[08:44:06] <Servus> class Tile : public BaseResource //actors and tiles arent mixed :-p
[08:44:14] <ShadwChsr> A vector lets you change the entire object to support the actual type/class you want to use, not an ancestor of it
[08:44:33] <ShadwChsr> They are though - becuase I have a "class ResourceCollection"
[08:44:53] <ShadwChsr> I dont want to program a "TileCollection", "ActorCollection", etc, each one with the exact same code, just with different parameter types
[08:44:58] <Servus> i guess i need to read up on templates...
[08:45:04] <-- Kirben2 has left IRC ("System Meltdown")
[08:45:16] <ShadwChsr> Well I barely know them, so don't trust me ;)
[08:45:37] <Servus> but you just havent told me anything yet that cant be done with classes, it was irks me :)
[08:45:49] <ShadwChsr> Sure I did
[08:46:04] <Servus> maybe i use classes more fully than you *grin*
[08:46:23] <ShadwChsr> I want 1 class that can return a Tile pointer and an Actor pointer, WITHOUT typecasting the result
[08:46:38] <ShadwChsr> if i use inheritence I only get a BaseResource *, not a Tile *
[08:46:55] <Servus> yeah i see
[08:47:44] <ShadwChsr> just cant figure out why it says its undefined :(
[08:47:55] <Servus> so template is inheritance, but parent didnt have to die :) (does that make sense...ack)
[08:48:13] <ShadwChsr> no ;)
[08:48:30] <Servus> well it makes sense to me
[08:48:33] <ShadwChsr> A template is kind of like dynamically changing datatypes without using overloading
[08:48:49] <Servus> ja i see :)
[08:53:46] * Servus 's eyeballs pop out... ow
[08:54:01] <ShadwChsr> I have a feeling templates' code need to be defined in the header :(
[08:54:58] <Darke> Yep. 'export' (IIRC) isn't actually supported by any current compilers. This is the keyword which should allow you to add the template code into a .cpp file.
[08:55:57] <ShadwChsr> :(
[08:56:08] <ShadwChsr> drat... makes no sense though :) Why didnt they add that in the first place? :)
[08:56:24] <Darke> `Most C++ compilers (G++ included) do not yet implement export, which is necessary for separate compilation of template declarations and definitions. Without export, a template definition must be in scope to be used. The obvious workaround is simply to place all definitions in the header itself. Alternatively, the compilation unit containing template definitions may be included from the header.`
[08:57:14] <Darke> It's non-trivial and contrary to what normally happens with C compilation and linking? *grin* IIRC it was also a late extension to the standard.
[08:58:44] <ShadwChsr> Well, I added it to the header and its STILL whining about data types
[08:58:55] <ShadwChsr> syntax error: Identifier "T"
[08:59:01] <Servus> hehehe
[09:03:06] <ShadwChsr> My god it finally compiled
[09:03:17] <ShadwChsr> now if only it would link ;-)
[09:03:55] <Servus> rebuild-all
[09:03:56] <ShadwChsr> there we go ;)
[09:04:02] <ShadwChsr> nah I missed a {}
[09:04:11] <ShadwChsr> since they all must be defined in the header
[09:04:11] <Servus> and it compiled but didnt link? whats your IDE?
[09:04:26] <ShadwChsr> After all that though... im debating if it was worth it ;-)
[09:04:40] <Servus> sure it was *pats you on head*
[09:04:45] <Servus> :P
[09:04:50] <ShadwChsr> my header file looks like chopped liver
[09:05:06] <ShadwChsr> I at least want to *hide* the fact I'm a newbie ;P
[09:05:32] <Servus> why do you think i act like a know-it-all jackass most of the time?
[09:06:45] <Servus> mmmm i want chili, bbs gotta drive out to the store
[09:07:13] <Servus> hello coren who has an idle time of 6 seconds
[09:07:53] <Servus> interesting how long ppl stay in here... well im off!
[09:17:34] --> Kirben has joined #exult
[09:17:34] --- ChanServ gives channel operator status to Kirben
[09:27:35] <Servus> hello kirben
[09:27:50] <Kirben> Hi
[10:41:51] <-- ShadwChsr has left IRC (Read error: 104 (Connection reset by peer))
[11:26:56] <-- Servus has left IRC ()
[12:43:40] --> Colourless has joined #Exult
[12:43:46] --- ChanServ gives channel operator status to Colourless
[12:43:53] <Colourless> HI!!!!!!
[12:45:53] <Colourless> ShadwChsr (if you see this)
[12:46:11] <Colourless> the solution to your Template problem is 'obvious'
[12:47:08] <Colourless> you still use template<class T>
[12:47:40] <Colourless> but you just always use T* everywhere, or use a typedef to define a pointer type
[12:48:55] <Colourless> now as for the 'other' problem, each compiler as a way to instantiate template classes to a type. It of course has limitations where you need to know what types you are using your class for
[12:50:27] * Darke blinkies and wonders if Matto is masquerading as a Colourless dragon. "Erm... hi."
[12:51:31] <Colourless> instantiating is done using:
[12:51:31] <Colourless> template class TemplateClassName<type>;
[12:54:58] <Colourless> it may be compiler specific as to where you may place the explicit instantiation. Normally it will need to be after all of the templated code
[12:57:11] <Colourless> in pentagram i use explicit template instantiation to use the same functions for both 16 bit and 32 bit rendering
[13:07:20] <-- Kirben has left IRC ("System Meltdown")
[13:07:29] * Darke paws the Wand of C++ Smiting +3 to Colourless.
[13:08:21] <Colourless> EVIL! Get it away from me. The power i would wield with such a creation would be unimagainable
[13:10:12] * Darke oooohshinies and uses it randomly smite innocent classes, and the occasional template function.
[13:10:39] <Darke> If you don't want to use it...
[13:11:43] <Colourless> it's best that I don't have it. don't want to become obsessed with C++. The wand is evil, in it's own ways
[13:11:58] <Colourless> it must be destroyed...
[13:12:21] <Colourless> it is like the one ring... just much much worse....
[13:15:22] * Darke rummages around and locates the +1, +2, and +4 Wands of C++ Smiting he's got, "Why? 'Cause there's multiple of them?"
[13:16:47] <Colourless> it's like a virus, of course there is more than one....
[13:18:07] <Colourless> you get one, you will want them all (sort of like Pokemon)
[13:18:27] <Colourless> once you start, you can never end
[13:18:30] * Darke is disappointed he doesn't have the +5 version. The only ones he know of are in posession of the Holy Clerics of GNU, Keepers of the great GCC. *pout*
[13:19:21] <Darke> I'm sure most of the VC++ coders are in possession of the cursed -5 versions of them. *grin*
[13:19:31] <Colourless> and look at the abomination of a compiler that is... slow.... memory hog....
[13:19:48] <Darke> Relatively standards complient... *grin*
[13:21:17] * Darke considers he really should get around to trying VC.NET on his flatmate's PC downstairs, if just 'cause he can gripe about whatever they've forgotten to fix from VC6. *grin*
[13:22:13] * Darke is lazy and plays Empire Earth instead. Evil game it is. Way too addicting it is.
[13:22:22] <Colourless> some standards complient features are off by default for combatibilty with MSVC6
[13:23:22] <Darke> I'm tempted to complain about that, but at least they've decided to allow you to try and be standards compliant. *grin*
[13:23:44] <Colourless> now, the std namespace for ANSI C headers probably still isn't 'fixed', but other than that from what I know, it's only mostly obsucre things that aren't complient
[13:26:30] * Darke yays!
[14:02:26] * Darke smites Colourless' compiler when it wanders too close. *smitesmiteSMITE*
[14:03:40] --- Colourless is now known as Cless|Away
[14:04:10] <Cless|Away> you didn't need to smite my compiler... it already has enough of it's own problems
[14:05:30] <Darke> Awwwww... but it's fun!
[14:54:46] --- Cless|Away is now known as Colourless
[14:55:24] <Coren_> gcc 3 r00x0rz!
[14:58:49] <-- Coren_ has left IRC ("using sirc version 2.211+KSIRC/1.2.4")
[15:58:53] * Darke wanders off in a vaguely zombie-sleepy fashion. Night!
[15:59:13] --- Darke is now known as DarkeZzz
[15:59:18] <Colourless> goodbye smalle rabbit
[16:00:25] <-- Colourless has left IRC ("brb")
[16:07:18] --> Colourless has joined #Exult
[16:07:20] --- ChanServ gives channel operator status to Colourless
[16:39:10] <jer|w0rk> hm
[21:24:02] <-- Colourless has left IRC ("casts invisibility")
[23:08:19] --> `daniel has joined #exult
[23:16:35] <-- Rixa has left IRC (Remote closed the connection)
[23:19:48] --> Kirben has joined #exult
[23:19:48] --- ChanServ gives channel operator status to Kirben
[23:50:28] <-- `daniel has left IRC ("Client Exiting")