digitalmars.D.learn - IsTuple returns true for Nullable!SomeTuple
- Ben Jones (4/4) Dec 01 2020 This seems like very surprising behavior to me. Is it a bug?
- Paul Backus (8/12) Dec 02 2020 No, this is not a bug, because Nullable!T currently has an
- Ben Jones (8/15) Dec 02 2020 I guess it's a moot point because the implicit conversion is
This seems like very surprising behavior to me. Is it a bug? import std.typecons; alias NT = Nullable!(Tuple!(int, double)); pragma(msg, isTuple!NT); //prints true!
Dec 01 2020
On Wednesday, 2 December 2020 at 05:25:09 UTC, Ben Jones wrote:This seems like very surprising behavior to me. Is it a bug? import std.typecons; alias NT = Nullable!(Tuple!(int, double)); pragma(msg, isTuple!NT); //prints true!No, this is not a bug, because Nullable!T currently has an implicit conversion to T via `alias this`. [1] However, this implicit conversion is deprecated, and will be removed in a future release. Once that happens, `isTuple!NT` will be `false`, as you'd expect. [1] http://phobos.dpldocs.info/std.typecons.Nullable.1.html#alias-this
Dec 02 2020
On Wednesday, 2 December 2020 at 12:59:52 UTC, Paul Backus wrote:No, this is not a bug, because Nullable!T currently has an implicit conversion to T via `alias this`. [1] However, this implicit conversion is deprecated, and will be removed in a future release. Once that happens, `isTuple!NT` will be `false`, as you'd expect. [1] http://phobos.dpldocs.info/std.typecons.Nullable.1.html#alias-thisI guess it's a moot point because the implicit conversion is deprecated, but it seems strange to me that isTuple behaves like canBeUsedAsTuple. Seems like the reasonable thing to do with a Nullable!(Tuple!Whatever) would be to check isTuple!(TemplateArgsOf!MyNullable) Thanks for the response
Dec 02 2020