You know you can spell it as
   x *hadamard* y
by defining
static constexpr hadamard_t final {
    struct hadamard_proxy_t {
        matrix const* m;
        friend auto operator*(hadamard_proxy_t const& self, matrix const& y) -> matrix {
            return hadamard_product(*self.m, y);
        }
    };
    friend auto operator*(matrix const& x, hadamard_t) -> hadamard_proxy_t {
        return hadamard_proxy_t{&x};
    }
};

I omitted the associativity helpers which are symmetric for brevity, and of course I completely neglected all the lvalue/rvalue forwarders, but it's close enough to give a hint.

G

On Mon, May 16, 2022 at 9:58 AM Patrik Tegelberg via Std-Proposals <std-proposals@lists.isocpp.org> wrote:

P.S. about overloading operator ->*.

Come to think of it, the dot product can not  use *= so I’ll let * mean point wise, which do use *= and let ->* mean dot product, so ->*= is never needed.

 

Sent from Mail for Windows

 

From: Sebastian Wittmeier via Std-Proposals
Sent: Sunday, 15 May 2022 22:08
To: std-proposals@lists.isocpp.org
Cc: Sebastian Wittmeier
Subject: Re: [std-proposals] Add operator for element wise multiplication.

 

Hi Patrik,

operator->* (pointer-to-member) can be overridden and is very similar in precedence to multiplication (one step higher only).

Best,

Sebastian

--

Sebastian Wittmeier

 

--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals