On Sun, 12 Oct 2014 20:29:39 +0000
JR via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote:

> Template the whole class? class A(alias ent)?

no, that will produce different classes for different types, and i need
just one class, but initialized with different entities. with templated
class i need to make A ancestor of some BaseA to make checks with
`cast(...)`.


On Sun, 12 Oct 2014 20:35:52 +0000
Cliff via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote:

> How about a static factory method?
i still need to call templated constructor with it. and i want to init
some immutable fields in it, and that fields depends of entity. sure, i
can write alot of non-templated constructors and call 'em from factory
method, or make other changes, but it leads to code bloat. i want to
avoid id.

> Or do you know there is a 
> syntax for invoking a templatized constructor and just can't 
> remember it?
no, i'm not even sure that such syntax exists. i always used templated
constructors with autodeduction.


On Sun, 12 Oct 2014 20:49:29 +0000
anonymous via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com>
wrote:

> I think there's no nice way to explicitly pass template arguments
> to constructors. Here's a hack:
i know about hackish way, but it's SOOO UUUGLY... ;-) thank you anyway.

> But the two leading underscores tell it: "__ctor" is an
> implementation detail. It may disappear/change without notice.
ah, that's ok, i'm relying on other implementation details too, one
more will not make much difference.


thank you people. seems that there is no "official" way to call such
constructors. ok, i converted it to autodeducing one, one more argument
doesn't really matter, it's hidden in another template anyway.

i was just curious if i missed some nice syntax here, or we have no way
to do this without resorting to hack or factory function.

Attachment: signature.asc
Description: PGP signature

Reply via email to