Implicit constructor call

Marcin Kuszczak aarti at interia.pl
Fri Jan 12 12:10:38 PST 2007


LeoD wrote:

> Hi,
> can constructors be called implicit in D? Example:
> 
> class Foo
> {
> this(int i)
> {
> 
> }
> }
> 
> void test(Foo f)
> {
> 
> }
> 
> int main()
> {
> test(100); // Here Foo.this(100); should get called
> 
> return 0;
> }
> 

No. But I agree that it could be nice addition to D.

> 
> And why are there no templated constructors in D? Example:
> 
> this(T)(T parameter)
> {
> 
> }

Same here. They are not templated in D, but would be nice if they will...

Hopefully Walter will add above features in future releases of DMD...

-- 
Regards
Marcin Kuszczak (Aarti_pl)
-------------------------------------
Ask me why I believe in Jesus - http://zapytaj.dlajezusa.pl (en/pl)
Doost (port of few Boost libraries) - http://www.dsource.org/projects/doost/
-------------------------------------




More information about the Digitalmars-d mailing list