www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Overriding behaviour of `is` for small-sized-optimized strings

reply Per =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
At

https://github.com/nordlow/phobos-next/blob/master/src/sso_string.d

I would like to override the behaviour of

     `x is y`

for `x` and `y` being instances of `SSOString`.

to always mean

     `x[] is y[]`

How do I do this?

Is this the recommended behaviour in D for small-size-optimized 
strings?
Nov 04 2018
parent reply Jacob Carlborg <doob me.com> writes:
On 2018-11-04 12:49, Per Nordlöw wrote:
 At
 
 https://github.com/nordlow/phobos-next/blob/master/src/sso_string.d
 
 I would like to override the behaviour of
 
      `x is y`
 
 for `x` and `y` being instances of `SSOString`.
 
 to always mean
 
      `x[] is y[]`
 
 How do I do this?
 
 Is this the recommended behaviour in D for small-size-optimized strings?
You cannot overload the the "is" operator. Use "==" if you want to overload it. -- /Jacob Carlborg
Nov 04 2018
parent Per =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
On Sunday, 4 November 2018 at 13:19:45 UTC, Jacob Carlborg wrote:
 You cannot overload the the "is" operator. Use "==" if you want 
 to overload it.
Ok, thanks.
Nov 04 2018