[GSOC] Database API

Kagamin spam at here.lot
Sat Mar 26 15:33:07 PDT 2011


Kagamin Wrote:

> Kagamin Wrote:
> 
> > Robert Jacques Wrote:
> > 
> > > > Should be Algebraic!(T, void). If that doesn't currently compile, we  
> > > > should make it compile.
> > > >
> > > > Andrei
> > > 
> > > For what it's worth, both Algebraic!(T, void*) and Algebraic!(T, void)  
> > > compile on my branch of std.variant.
> > 
> > can't assign null
> > 
> > 	alias Algebraic!(int,void) nint;
> > 	nint n1=5;
> > 	assert(n1==5);
> > 	n1=null;
> > 
> > \std\variant.d:497: Error: static assert  "Cannot store a void* in a VariantN!(maxSize,int,void). Valid types are (int, void)"
> > test.d:45:        instantiated from here: opAssign!(void*)
> 
> Ahh, there's a workaround:
> 
> 	alias Algebraic!(int,void) nint;
> 	nint n1=5;
> 	assert(n1.get!(int)==5);
> 	n1=nint(); //uninitialized Variant, sort of null
> 	assert(!n1.hasValue);
> 	assert(n1.peek!(int)==null);
> 	writeln("error here:");
> 	assert(n1.get!(int)==0);

this also works without allowing void!

	alias Algebraic!(int) nint;
	nint n1=5;
	assert(n1.get!(int)==5);
	n1=nint(); //still null
	assert(!n1.hasValue);
	assert(n1.peek!(int)==null);
	writeln("error:");
	assert(n1.get!(int)==0);


More information about the Digitalmars-d mailing list