🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Niklas Hallqvist Mon, 11 Feb 1991 15:20
Proposal: template default arguments
#825
Author: Niklas Hallqvist
Date: Mon, 11 Feb 1991 15:20
36 lines
1660 bytes
	Hello!

	I've just read chapter 14 of the ARM and are thrilled by
the possibilities with templates, especially together with MI.
Up to this point I've been experimenting with CPP macros and the
GNU genclass utility.  However, there is a slight change I'd like
to see: default template arguments.  For example:

template<class T = void*, int size = 1024> class Stack {
private:
  T rep[size];
public:
  ...
};

void foo();
  Stack<> a;		// A Stack<void*, 1024>
  Stack<char*> b;	// A Stack<char*, 1024>
  Stack<char*, 512> c;	// Well, what do you think!!!
}

How about this?  Are there any problems implementing this?  It's
quite consistent with the way ordinary default arguments work.
And please, don't flame me for wanting to throw in yet another feature
in the language.  I wouldn't have posted this if didn't know that
it wouldn't break any old programs, or thought it would increase
the obscurity level of c++.  As I said: This is consistent with
other features already found in the language!

				Niklas
-- 
Niklas Hallqvist	Phone: +46-(0)31-40 75 00
Applitron Datasystem	Fax:   +46-(0)31-83 39 50
Molndalsvagen 95	Email: niklas@appli.se
S-412 63  GOTEBORG, Sweden     mcsun!sunic!chalmers!appli!niklas
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads