View mode: basic / threaded / horizontal-split · Log in · Help
March 17, 2008
Re: Alternative solutions to returning ref types.
Christopher Wright Wrote:
> Have you tried it with any UDTs that don't overload all those operators? 
> The unary operators will die; the binary ones are hidden behind 
> templates so they're okay unless someone uses them.
> 
> You'll need guards like:
> T opNeg()
> {
> 	static if (is (typeof(-(*data))))
> 	{
> 		return -(*data);
> 	}
> 	else
> 	{
> 		assert (false, "type " ~ T.stringof ~ " does not support this operator."
> 	}
> }
>

Right. Tried it before I added the unary operators, forgot to test those. Thanks.

-- Simen
Top | Discussion index | About this forum | D home