On Friday, 17 April 2015 at 13:33:36 UTC, Adam D. Ruppe wrote:
On Friday, 17 April 2015 at 13:27:19 UTC, Biotronic wrote:
void foo(T)(T a) {}
foo!T(0);
Does foo(T(0)); work? It seems like it should
void foo(T)(T a) {}
import std.bigint;
import std.complex;
void main() {
I've been writing a lot of generic code lately that has to deal
with various kinds of numbers, and have near been driven nuts by
the fact there is no uniform way to get a zero or one.
Consider:
void foo(T)(T a) {}
foo!T(0);
Does this work with all built-in numeric types? Yes.
Does it
On Friday, 17 April 2015 at 13:27:19 UTC, Biotronic wrote:
void foo(T)(T a) {}
foo!T(0);
Does foo(T(0)); work? It seems like it should
void foo(T)(T a) {}
import std.bigint;
import std.complex;
void main() {
foo(BigInt(0));
foo(float(0));
foo(int(0));
On Fri, 17 Apr 2015 13:27:18 +, Biotronic wrote:
would work. But why can't I instead, for every numeric type, simply
write
foo(BigInt.zero); foo(float.one); foo(Complex!float.zero);
foo(Rational!BigInt.one);
foo(Meters.zero);
Omens.sixsixsix...
signature.asc
Description:
On Friday, 17 April 2015 at 13:27:19 UTC, Biotronic wrote:
I've been writing a lot of generic code lately that has to deal
with various kinds of numbers, and have near been driven nuts
by the fact there is no uniform way to get a zero or one.
Consider:
void foo(T)(T a) {}
foo!T(0);