Article View: comp.std.c++
Article #2123Why no constraint templates ?
From: Valery Croizier
Date: Thu, 05 Oct 1995 18:05
Date: Thu, 05 Oct 1995 18:05
30 lines
1497 bytes
1497 bytes
Sometimes, I wish I could oblige the user of a template class to
inherit from a given class:
class Shape {
public:
void draw() = 0;
};
template <class T inherits from Shape>
class ListOfShape {
public:
// ...
void drawAll();
};
Of course, the above is just an example, and we can find many other
use of such a kind of template. The main advantage is compile-time
type-checking: when you write the implementation of the template class,
you cannot call a bad method.
o Is there a way I have not noticed to do this ?
o Does anybody know the reason why the team working on the
standard rejected this feature ?
--
Valery
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<4510ou$11m3@melimelo.enst-bretagne.fr>Path:
arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamageShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage From: croizier@rennes.enst-bretagne.fr (Valery Croizier) Newsgroups: comp.std.c++ Subject: Why no constraint templates ? Date: 5 Oct 1995 18:05:30 GMT Organization: ENST Bretagne Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <4510ou$11m3@melimelo.enst-bretagne.fr> NNTP-Posting-Host: taumet.eng.sun.com Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII"; conversions="7bit" Content-Transfer-Encoding: 7bit Keywords: template X-Nntp-Posting-Host: malco.rennes.enst-bretagne.fr X-Lines: 26 Content-Length: 630 Originator: clamage@taumet