Article View: comp.std.c++
Article #825Proposal: template default arguments
From: Niklas Hallqvist
Date: Mon, 11 Feb 1991 15:20
Date: Mon, 11 Feb 1991 15:20
36 lines
1660 bytes
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
Technical Details
Message-ID:
<1272@appli.se>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!ncar!gatech!bloom-beacon!eru!hagbard!sunic!chalmers.se!appli!niklasShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!ncar!gatech!bloom-beacon!eru!hagbard!sunic!chalmers.se!appli!niklas From: niklas@appli.se (Niklas Hallqvist) Newsgroups: comp.std.c++ Subject: Proposal: template default arguments Message-ID: <1272@appli.se> Date: 11 Feb 91 15:20:09 GMT Organization: Applitron Datasystem AB, GOTHENBURG, SWEDEN Lines: 36