[Issue 10394] opBinaryRight!"in" and tuple

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jul 15 15:45:26 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10394



--- Comment #3 from Justin Whear <justin at economicmodeling.com> 2013-07-15 15:45:23 PDT ---
An update on this issue: we have worked around this by switching away from "in"
to a method-based approach, so this is no longer blocking for the reporter.  I
think this issue remains valid until it's decided whether the "in" operator (or
operators in general) will allow a tuple on the left hand side.  Here's a
simplified example that matches with our use case:
-----------------------------
struct Graph(T, Address...)
{
    struct Node
    {
        Address address;
        T payload;
    }

   ...

   Node* opBinaryRight(string op)(Address address) if (op == "in)
   {
       ...
   }
}

void main()
{
    Graph!(double, int, string) graph;
    auto node = ...procure a node from somwhere...

    // node.address is preferred to tuple(node.address)
    if (auto inGraph = node.address in graph)
    {
        ...
    }
}
-----------------------------

As I said, we have worked around this because it's not unreasonable for binary
operators to only allow one value on each side, but it was also nice to have
this kind of syntax in 2.062 and previous.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list