On 04/09/2014 08:53 PM, Benjamin Thaut wrote:
Am 09.04.2014 20:33, schrieb Timon Gehr:
On 04/09/2014 04:59 PM, Benjamin Thaut wrote:
Why not just:
struct Foo{
this(){
// do stuff here
}
}
void main(){
Foo foo1; // error, no init value
auto foo2=Foo(); // ok
}
Because then the user might think, that the default constructor gets
called implicitly by the compiler.
This would be pointed out by the compiler. (i.e. it is an error instead
of an implicit call.)
Just like in C++. But as that is not
the case the syntax should be different to indicate that a struct might
still be instaniated just using T.init.
Kind Regards
Benjamin Thaut
What would be an use case for a bypassable default constructor?