On Wednesday, 14 November 2012 at 07:26:44 UTC, Tove wrote:
it would be a very useful feature to allow overload on void and 1 other type... as sometimes the return is very expensive to calculate... I have seen this trick used by compiler build-in functions.

struct A
{
  int i;
  string s;

  alias i this;
  alias s this;
}

but... 2 alias this are not currently allowed.

Was the single conversion limitation specified by design, or do we have room to expand it to allow for multiple conversions?

In C++ I used multiple conversions for a variant class and it worked like a charm. The alternative was to manually specify a named function based on the type to return, which is not as fun to work with.

--rt

Reply via email to