std.conv.roundTo does not accept const/immutable/shared for its Source. These attributes won't pass static asserts in std.conv.roundTo. e.g.: immutable real a = -2.3; int b = roundTo!(int)(a); // failure int c = cast(int)std.math.round(a); // success It seems that static asserts in std.conv.roundTo should be replaced by std.traits.isIntegral and std.traits.isFloatingPoint. p.s. I suppose roundTo is able to be pure function.
Fixed. Purity is pending issue 3269.