Re: Prevent default-initialised struct

2009-01-28 Thread Christopher Wright
Daniel Keep wrote: Hi all, is there any way to prevent a struct from being created directly? Basically, I want to prevent this: { non_null!(T) a; } I want people to have to use provided functions to create a structure: { auto a = non_null!(T)(new T); } -- Daniel struct non_null(T : c

Re: Prevent default-initialised struct

2009-01-28 Thread Daniel Keep
grauzone wrote: > Use a class instead. That would defeat the purpose of defining a non_null template in the first place. -- Daniel

Re: Prevent default-initialised struct

2009-01-28 Thread grauzone
I think it would really suck to introduce special cases to forbid default initialization of structs. And assuming T was the type of the struct, what would T.init do? Or typeid(T).init()? Use a class instead. If you really need a struct, you could use a private field, that signals if the struc

Re: Prevent default-initialised struct

2009-01-26 Thread Denis Koroskin
On Mon, 26 Jan 2009 20:40:01 +0300, BCS wrote: Hello Daniel, Hi all, is there any way to prevent a struct from being created directly? Basically, I want to prevent this: { non_null!(T) a; } I want people to have to use provided functions to create a structure: { auto a = non_null!(T)(new T

Re: Prevent default-initialised struct

2009-01-26 Thread BCS
Hello Daniel, Hi all, is there any way to prevent a struct from being created directly? Basically, I want to prevent this: { non_null!(T) a; } I want people to have to use provided functions to create a structure: { auto a = non_null!(T)(new T); } -- Daniel struct S { private static S opCa

Prevent default-initialised struct

2009-01-26 Thread Daniel Keep
Hi all, is there any way to prevent a struct from being created directly? Basically, I want to prevent this: { non_null!(T) a; } I want people to have to use provided functions to create a structure: { auto a = non_null!(T)(new T); } -- Daniel