On Friday, 17 June 2022 at 12:53:53 UTC, bauss wrote:

Just add a constructor to your type that takes the value of what you want to convert.

Isn't foo and bar the same thing? I don't understand what's the difference! By the way, what's the question? Is this the answer to the question?

```d
void main()
{
  auto foo = to!Foo("123"); //??
  typeid(foo).writeln(": ", foo);

  assert("123".to!Foo == foo);
  assert(123.to!Foo == foo);

  auto bar = Foo("321");
  typeid(bar).writeln(": ", bar);

  assert("321".to!Foo == bar);
  assert(321.to!Foo == bar);
}
```
SDB@79

Reply via email to