https://issues.dlang.org/show_bug.cgi?id=12597
Issue ID: 12597
Summary: Payload getter for std.typecons.Typedef
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: Phobos
Assignee: [email protected]
Reporter: [email protected]
Currently if you want to call a function sin/cos on a Typedef (here used to
define a strongly typed angle), you need a cast:
void main() {
import std.typecons: Typedef;
import std.math: sin;
alias Angle = Typedef!double;
Angle x = 0.5;
auto y1 = sin(x); // Error.
auto y2 = sin(cast(double)x); // OK.
}
So to avoid the unsafe cast I suggest to add a getter to Typedef:
auto y3 = sin(x.get);
--