D - template constructors?
- Chris Sauls (20/20) Jan 29 2004 Would the following be possible?
- C (21/41) Jan 29 2004 Thats a template function declration , for a class this will work
- Chris Sauls (16/73) Jan 29 2004 This is why I ask silly questions. Knew there had to be a way for it.
- Robert (19/92) Jan 29 2004 Maybe, the following is what you want.
Would the following be possible?
/* snip */
template Foo(T) {
this() {
// init? registration? factory work? etc
// called on first use of 'Foo!(bob)' for each different 'bob'
}
~this() {
// uninit, unregister, retire, etc
// called alongside module's static ~this()?
// and/or implement 'delete Foo!(bob);'
}
// then the usual junk from here on
T _bar;
void baz() {
}
}
/* /snip */
--Chris S.
--Invironz
Jan 29 2004
Thats a template function declration , for a class this will work
class Foo(T) {
this() {
// init? registration? factory work? etc
// called on first use of 'Foo!(bob)' for each different 'bob'
}
~this() {
// uninit, unregister, retire, etc
// called alongside module's static ~this()?
// and/or implement 'delete Foo!(bob);'
}
// then the usual junk from here on
T _bar;
void baz() {
}
}
void main () {
Foo!(int) x= new Foo!(int);
}
"Chris Sauls" <ibisbasenji yahoo.com> wrote in message
news:bvbkdr$2js1$1 digitaldaemon.com...
Would the following be possible?
/* snip */
template Foo(T) {
this() {
// init? registration? factory work? etc
// called on first use of 'Foo!(bob)' for each different 'bob'
}
~this() {
// uninit, unregister, retire, etc
// called alongside module's static ~this()?
// and/or implement 'delete Foo!(bob);'
}
// then the usual junk from here on
T _bar;
void baz() {
}
}
/* /snip */
--Chris S.
--Invironz
Jan 29 2004
This is why I ask silly questions. Knew there had to be a way for it.
Danke.
Now I assume then that if I had a class defined as:
class Foo(T) {
this(char[] arg) {
}
}
That I would instantiate in the obvious way:
void main() {
Foo!(int) x = new Foo!(int)("arg");
}
And that I could freely use 'Foo!(int)' as a static reference. If so,
its all sweetness.
--Chris S.
--Invironz
C wrote:
Thats a template function declration , for a class this will work
class Foo(T) {
this() {
// init? registration? factory work? etc
// called on first use of 'Foo!(bob)' for each different 'bob'
}
~this() {
// uninit, unregister, retire, etc
// called alongside module's static ~this()?
// and/or implement 'delete Foo!(bob);'
}
// then the usual junk from here on
T _bar;
void baz() {
}
}
void main () {
Foo!(int) x= new Foo!(int);
}
"Chris Sauls" <ibisbasenji yahoo.com> wrote in message
news:bvbkdr$2js1$1 digitaldaemon.com...
Would the following be possible?
/* snip */
template Foo(T) {
this() {
// init? registration? factory work? etc
// called on first use of 'Foo!(bob)' for each different 'bob'
}
~this() {
// uninit, unregister, retire, etc
// called alongside module's static ~this()?
// and/or implement 'delete Foo!(bob);'
}
// then the usual junk from here on
T _bar;
void baz() {
}
}
/* /snip */
--Chris S.
--Invironz
Jan 29 2004
Maybe, the following is what you want.
class Foo(T) {
private static T _bar;
static this() {
// initialize _bar
}
static ~this() {
// finalize _bar
}
static void baz() {
// use _bar
}
}
int main() {
Foo!(int).baz();
return 0;
}
"Chris Sauls" <ibisbasenji yahoo.com> wrote in message
news:bvbsld$om$1 digitaldaemon.com...
This is why I ask silly questions. Knew there had to be a way for it.
Danke.
Now I assume then that if I had a class defined as:
class Foo(T) {
this(char[] arg) {
}
}
That I would instantiate in the obvious way:
void main() {
Foo!(int) x = new Foo!(int)("arg");
}
And that I could freely use 'Foo!(int)' as a static reference. If so,
its all sweetness.
--Chris S.
--Invironz
C wrote:
Thats a template function declration , for a class this will work
class Foo(T) {
this() {
// init? registration? factory work? etc
// called on first use of 'Foo!(bob)' for each different 'bob'
}
~this() {
// uninit, unregister, retire, etc
// called alongside module's static ~this()?
// and/or implement 'delete Foo!(bob);'
}
// then the usual junk from here on
T _bar;
void baz() {
}
}
void main () {
Foo!(int) x= new Foo!(int);
}
"Chris Sauls" <ibisbasenji yahoo.com> wrote in message
news:bvbkdr$2js1$1 digitaldaemon.com...
Would the following be possible?
/* snip */
template Foo(T) {
this() {
// init? registration? factory work? etc
// called on first use of 'Foo!(bob)' for each different 'bob'
}
~this() {
// uninit, unregister, retire, etc
// called alongside module's static ~this()?
// and/or implement 'delete Foo!(bob);'
}
// then the usual junk from here on
T _bar;
void baz() {
}
}
/* /snip */
--Chris S.
--Invironz
Jan 29 2004








"Robert" <no spam.ne.jp>