Re: Associative Array, get value instead of poiter using `if (auto ..)`, possible?

2024-09-01 Thread ryuukk_ via Digitalmars-d-learn
On Sunday, 1 September 2024 at 03:06:53 UTC, Paul Backus wrote: On Saturday, 31 August 2024 at 22:06:26 UTC, kdevel wrote: Is that functionally different from ``` void main() { import std.stdio; int[string] test = ["hello": 42]; if (auto p = "hello" in test) { writeln(

Re: Associative Array, get value instead of poiter using `if (auto ..)`, possible?

2024-09-01 Thread evilrat via Digitalmars-d-learn
On Sunday, 1 September 2024 at 08:50:53 UTC, ryuukk_ wrote: if checking for/getting a value from a hashmap requires all that crap, then perhaps something is wrong with the language, and it perhaps isn't the one i should have picked for the task my mistake perhaps, not yours besides, i do u

Adding a partial specialization of std.conv.to for Typedef!string

2024-09-01 Thread kdevel via Digitalmars-d-learn
In order to make this work ```d import std.typecons; alias vstring = Typedef!string; void main () { import std.stdio; import std.conv; auto v = 3.to!vstring; // ain't work out of the box writeln (v); auto w = 3.to!string; writeln (w); long l = 3.to!long; writeln (l);

Re: Adding a partial specialization of std.conv.to for Typedef!string

2024-09-01 Thread monkyyy via Digitalmars-d-learn
On Sunday, 1 September 2024 at 11:01:13 UTC, kdevel wrote: In order to make this work ```d import std.typecons; alias vstring = Typedef!string; void main () { import std.stdio; import std.conv; auto v = 3.to!vstring; // ain't work out of the box writeln (v); auto w = 3.to!stri

Re: Associative Array, get value instead of poiter using `if (auto ..)`, possible?

2024-09-01 Thread kdevel via Digitalmars-d-learn
On Saturday, 31 August 2024 at 13:48:52 UTC, ryuukk_ wrote: On Saturday, 31 August 2024 at 13:00:42 UTC, Steven Schveighoffer wrote: On Saturday, 31 August 2024 at 12:47:25 UTC, ryuukk_ wrote: ```D void main() { int[string] test; test["hello"] = 42; if (auto it = "hello" in test)