Tired by deprecation message for unary operators on 8/16 bit vars ? A simple solution

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Jun 7 16:05:37 UTC 2018


On Thu, Jun 07, 2018 at 03:52:10PM +0000, Basile B. via Digitalmars-d wrote:
> On Thursday, 7 June 2018 at 15:18:49 UTC, H. S. Teoh wrote:
> > On Thu, Jun 07, 2018 at 01:42:17PM +0000, Basile B. via Digitalmars-d
> > wrote:
> > > [...]
> > [...]
> > 
> > You're on the right track. Now all you have to do is to add operator
> > overloading to make the wrapper type infectious, and a convenience
> > function that can be easily typed, and you get:
> > 
> > [...]
> 
> Yeah nice, but it can be more simply used _just_ when the unary
> operator would lead to the message (with ctor: ~SomeType(...).

The same deprecation message appears when doing simple arithmetic with
narrow int types, like `byte b = cast(byte) 10 + cast(byte) 20;`. The
.np wrapper gets rid of all that, with the added bonus of documenting
the programmer's intent in the code.


T

-- 
English is useful because it is a mess. Since English is a mess, it maps well onto the problem space, which is also a mess, which we call reality. Similarly, Perl was designed to be a mess, though in the nicest of all possible ways. -- Larry Wall


More information about the Digitalmars-d mailing list