On Thursday, 15 February 2018 at 00:34:33 UTC, Meta wrote:
On Thursday, 15 February 2018 at 00:27:40 UTC, Meta wrote:
On Wednesday, 14 February 2018 at 23:46:30 UTC, aliak wrote:
On Wednesday, 14 February 2018 at 15:14:24 UTC, Meta wrote:
Ooh yes, of course! Thank you :)
Even better:
import
On Thursday, 15 February 2018 at 00:27:40 UTC, Meta wrote:
On Wednesday, 14 February 2018 at 23:46:30 UTC, aliak wrote:
On Wednesday, 14 February 2018 at 15:14:24 UTC, Meta wrote:
Ooh yes, of course! Thank you :)
Even better:
import std.conv;
auto b = a.map!(to!float);
Actually, that won'
On Wednesday, 14 February 2018 at 23:46:30 UTC, aliak wrote:
On Wednesday, 14 February 2018 at 15:14:24 UTC, Meta wrote:
I think the best way to do this is to implement `map` for your
optional type.
Optional!U map(U, alias f)()
{
return empty? no!U : some!U(f(t));
}
Optional!int a = 3;
On Wednesday, 14 February 2018 at 15:14:24 UTC, Meta wrote:
I think the best way to do this is to implement `map` for your
optional type.
Optional!U map(U, alias f)()
{
return empty? no!U : some!U(f(t));
}
Optional!int a = 3;
auto b = a.map!(v => cast(float)v);
assert(is(typeof(b) == Opt
On Monday, 12 February 2018 at 02:05:16 UTC, aliak wrote:
From spec: Cast expression: "cast ( Type ) UnaryExpression"
converts UnaryExpresssion to Type.
And https://dlang.org/spec/operatoroverloading.html#cast makes
no mention of the return type of opCast. One could think that
the return type
On Tuesday, 13 February 2018 at 12:12:30 UTC, Nathan S. wrote:
On Monday, 12 February 2018 at 02:05:16 UTC, aliak wrote:
struct B(T) {
T t;
}
struct A(T) {
T t;
auto opCast(U)() {
return B!U(cast(U)t);
}
}
void main() {
auto a = A!int(3);
auto b = cast(float)a;
On Monday, 12 February 2018 at 02:05:16 UTC, aliak wrote:
struct B(T) {
T t;
}
struct A(T) {
T t;
auto opCast(U)() {
return B!U(cast(U)t);
}
}
void main() {
auto a = A!int(3);
auto b = cast(float)a; // error
}
Having the result of "cast(float) a" not be a float
On Monday, 12 February 2018 at 02:05:16 UTC, aliak wrote:
From spec: Cast expression: "cast ( Type ) UnaryExpression"
converts UnaryExpresssion to Type.
And https://dlang.org/spec/operatoroverloading.html#cast makes
no mention of the return type of opCast. One could think that
the return type
From spec: Cast expression: "cast ( Type ) UnaryExpression"
converts UnaryExpresssion to Type.
And https://dlang.org/spec/operatoroverloading.html#cast makes no
mention of the return type of opCast. One could think that the
return type of opCast would be the return type. But it seems it
must