On 05.09.2016 14:31, Adam D. Ruppe wrote:
On Monday, 5 September 2016 at 09:59:16 UTC, Andrea Fontana wrote:
I asked this some time (years?) ago. Time for a second try :)

Return type deduction probably won't work,

Why? It seems rather easy to do.

but implicit casts of a
custom data type could do this - that's how C++ would do it.
...

That does not solve the problem that nicely: if no different type is specified the dummy object with the opImplicitCast can be assigned to a variable:

auto x = a.get(); // oops

This shouldn't compile.

Alas, D does not have an implicit cast operator :( best we have is
`alias this` but it only allows one right now (despite the book saying
it is supposed to do multiple.. and there are some PRs about it). They
wouldn't be templated but json could just do a few implicit casts.

Reply via email to