Article View: comp.std.c++
Article #758Re: The concept of templates considered ill designed
From: Stefan Monnier
Date: Tue, 06 Oct 1992 23:31
Date: Tue, 06 Oct 1992 23:31
51 lines
2502 bytes
2502 bytes
Excerpts from netnews.comp.lang.c++: 6-Oct-92 Re: The concept of
template.. Andrew Koenig@alice.att. (1825)
> If we call f with an argument of type Bar, it will fail during instantiation
> with an ambiguity error. The only way to avoid this is to say that the type
> constraint also constrains the call of t.mem(0) to just those instances of
> mem defined in the base class -- but in that case, you will still get in
> trouble with this one:
> class Baz: public Foo {
> public:
> void mem(long);
> void mem(double);
> };
> because now *neither* of the variants of Baz::mem matches the one in Foo.
> Thus, you have two choices:
> 1. Attempt to call Baz::mem(int), which doesn't exist;
> 2. Call Foo::mem(int), in which case you might as well not
> bother using templates at all, or
> 3. Give an ambiguity error, in which case you can't type-check
> the original template.
> My point in giving this example is to show that statements like `constraining
> template types makes compile-time type checking possible' cannot be made
> casually -- it is the responsibility of the person making such a statement
> to provide evidence that the statement is indeed true.
> This stuff is **difficult**! Don't take it lightly!
> --
> --Andrew Koenig
> ark@europa.att.com
What's the problem ?
Why not take option 2 ?
Every Baz object has method Foo::mem(int) cause it has inherited it
from Foo.
If you don't agree with it, why use inheritance ?
And if you would like it to call anything else, then you programming
style seems weird to me !!!
Stefan
-----------------------------------------------------
-- On the average, people seem to be acting normal --
-----------------------------------------------------
Technical Details
Message-ID:
<IeoW7Ca00awVEGbFIn@andrew.cmu.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!wupost!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!news.sei.cmu.edu!fs7.ece.cmu.edu!crabapple.srv.cs.cmu.edu!andrew.cmu.edu!sm86+References:
<RAYMOND.92Sep29122502@cobra.es.ele.tue.nl> <0enxJ1W00awTMNepU8@andrew.cmu.edu> <23808@alice.att.com> <Yeo91je00awVE_zEkI@andrew.cmu.edu> <23822@alice.att.com>Show Full Headers
Complete Article Headers
Organization: Junior, Math/Computer Science, Carnegie Mellon, Pittsburgh, PA Path: arc1-ca.pugleaf.net!sparky!uunet!wupost!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!news.sei.cmu.edu!fs7.ece.cmu.edu!crabapple.srv.cs.cmu.edu!andrew.cmu.edu!sm86+ Newsgroups: comp.std.c++,comp.lang.c++ Message-ID: <IeoW7Ca00awVEGbFIn@andrew.cmu.edu> Date: Tue, 6 Oct 1992 19:31:26 -0400 From: Stefan Monnier <osoelgaultier+@CMU.EDU> Subject: Re: The concept of templates considered ill designed In-Reply-To: <23822@alice.att.com> References: <RAYMOND.92Sep29122502@cobra.es.ele.tue.nl> <0enxJ1W00awTMNepU8@andrew.cmu.edu> <23808@alice.att.com> <Yeo91je00awVE_zEkI@andrew.cmu.edu> <23822@alice.att.com> Lines: 56