D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3239 - std.conv.roundTo does not accept const/immutable/shared
Summary: std.conv.roundTo does not accept const/immutable/shared
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: Andrei Alexandrescu
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2009-08-10 02:29 UTC by HOSOKAWA Kenchi
Modified: 2015-06-09 01:28 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description HOSOKAWA Kenchi 2009-08-10 02:29:21 UTC
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.
Comment 1 Andrei Alexandrescu 2009-08-28 11:05:42 UTC
Fixed. Purity is pending issue 3269.