Re: Why does this template constraint not work?

2013-12-27 Thread Ross Hays
On Saturday, 28 December 2013 at 02:27:00 UTC, Ross Hays wrote: import std.stdio; void test(T)() if (is (T : float)) { writeln(typeid(T)); } void main() { test!int; } When I run this I am getting the output int My understanding of template constraints is that the call

Re: Why does this template constraint not work?

2013-12-27 Thread Jonathan M Davis
On Saturday, December 28, 2013 02:31:56 Ross Hays wrote: Okay figured it out actually. If you are not going to allow implicit conversion the appropriate constraint is... if (is (T == float)) If you want to accept any floating point type but not implicit conversions, then use

Re: Why does this template constraint not work?

2013-12-27 Thread Ross Hays
If you want to accept any floating point type but not implicit conversions, then use std.traits.isFloatingPoint. Thank you that's good to know. Though for this particular example I was just making a basic demo of the problem.