Topic: Template for Smart Pointer
Author: djones@megatest.com (Dave Jones)
Date: Mon, 4 Apr 1994 04:31:27 GMT Raw View
> Only languages like Cluster that supports dynamic genericity can fully
> support what you need ...
If by "dynamic" you mean, "calculated at runtime", that's not what I want.
Bjarne says he is going to submit a proposal to the committe for
passing template names to templates at compile time. That's what I want.
Hope it passes.
> It can do NOTHING with DYNAMIC binding,
> which is the basic requirement for any POINTER protocol.
Huh?
I don't know what you are getting at, but whatever it is that
not be calculated at compile-time is not what I'm thinking of.
I just want to be able to pass references to templates as parameters
to templates, at compile time.
tempate<class T, template Ptr<class M> >
class Container {
private:
Ptr< Cons<T> > TConsPtr;
};
Author: shang@corp.mot.com (David L. Shang)
Date: Fri, 8 Apr 1994 21:43:02 GMT Raw View
In article <Cnpx01.22t@megatest.com> djones@megatest.com (Dave Jones) writes:
> > Only languages like Cluster that supports dynamic genericity can fully
> > support what you need ...
>
> If by "dynamic" you mean, "calculated at runtime", that's not what I want.
> Bjarne says he is going to submit a proposal to the committe for
> passing template names to templates at compile time. That's what I want.
> Hope it passes.
>
If you do not require that your smart pointer can be used as a normal pointer,
it's fine. That means, there will be no dynamic binding with your smart
pointer. No polymorphism.
> > It can do NOTHING with DYNAMIC binding,
> > which is the basic requirement for any POINTER protocol.
>
> Huh?
>
> I don't know what you are getting at, but whatever it is that
> not be calculated at compile-time is not what I'm thinking of.
> I just want to be able to pass references to templates as parameters
> to templates, at compile time.
>
> tempate<class T, template Ptr<class M> >
> class Container {
> private:
> Ptr< Cons<T> > TConsPtr;
> };
>
This ia really a confused declaration. If class parameter T is not constrained,
why have a signature-like contraint <class M> with template parameter Ptr? The
name M is actually useless, but casues confusion.
Okay, let's take that form (with a pain in reading). But remember, you can only
use Ptr in template for static "polymorphism".
What the major role a pointer in C++ object-oriented programming? Of cause
dynamic binding. You cannot have that by template Ptr.
If you do not need such dynamic binding with your smart pointer, it's fine. But
don't be scared away by "calculation at runtime". It is not a more expensive
way than using a normal pointer with dynamic binding. An indirect access
instruction is the overhead in Cluster.
David Shang