sixthDot 3 hours ago

I cannot reply on the blog but to answer the author about other languages, here is the D version, using a single template:

    auto ref T max(T)(auto ref T u, auto ref T v) => u > v ? u : v;
    
    void main()
    {
        int a = 1;
        int b = 0;
        int x;

        static assert(__traits(compiles, &max(a,b) == &a),
            "should have selected the lvalue version");
        static assert(__traits(compiles, x = max(1,0)),
            "should have selected the rvalue version");
        static assert(__traits(compiles, x = max(a,0)),
            "should have selected the rvalue version");
        static assert(__traits(compiles, x = max(1,0)),
            "should have selected the rvalue version");
    }