static if on types like double, float

Daniel Keep daniel.keep.lists at gmail.com
Wed Jun 14 06:23:53 PDT 2006



sclytrack at pi.be wrote:
> I have the following class, called SingularValueDecomposition, it should only
> accept T of type float and double. Currently, it uses dgesvd for double, but for
> float it must call sgesvd.
> 
> 1. How can I do a static if on a type? (Thanks in advance.)
> 
> [snip]

# static if( is( T == float ) )
# 	/* stuff */
# else static if( is( T == double ) )
# 	/* more stuff */
# else
# {
# 	pragma(msg, "It's floats, doubles or nothing!");
# 	static assert(false);
# }

You might be able to use ``static assert(false, "...");`` to show a
message, maybe not.  I know you can pass the message to the non-static
version, but I can't remember if the static one supports that.

	-- Daniel

-- 
Unlike Knuth, I have neither proven or tried the above; it may not even
make sense.

v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D
i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP  http://hackerkey.com/



More information about the Digitalmars-d-learn mailing list