Offending line in map: alias typeof(_fun(.ElementType!R.init)) ElementType;
So it tires to pass .init which will be nan for floats. A quick workaround would be: static if (isFloatingPoint!(ElementType!R)) { .ElementType!R x; alias typeof(_fun(x)) ElementType; } else { alias typeof(_fun(.ElementType!R.init)) ElementType; } Also, my example was just a little flawed (semantically speaking), since I was missing a return statement: double[10] arr; arr[] = 1.0; auto result = map!((ref double sample){ return 1.0; })(arr[]); This will then work with that change.