Re: Checked!({short, ushort, byte, ubyte}, Throw): compilation fails

2020-04-18 Thread tsbockman via Digitalmars-d-learn
On Saturday, 18 April 2020 at 15:20:42 UTC, kdevel wrote: On Saturday, 18 April 2020 at 08:39:52 UTC, tsbockman wrote: https://code.dlang.org/packages/checkedint Hm. $ dub test Generating test runner configuration 'checkedint-test-library' for 'library' (library). Excluding package.d fil

Re: Checked!({short, ushort, byte, ubyte}, Throw): compilation fails

2020-04-18 Thread tsbockman via Digitalmars-d-learn
On Saturday, 18 April 2020 at 15:20:42 UTC, kdevel wrote: On Saturday, 18 April 2020 at 08:39:52 UTC, tsbockman wrote: https://code.dlang.org/packages/checkedint Hm. $ dub test Generating test runner configuration 'checkedint-test-library' for 'library' (library). Excluding package.d fil

Re: Checked!({short, ushort, byte, ubyte}, Throw): compilation fails

2020-04-18 Thread kdevel via Digitalmars-d-learn
On Saturday, 18 April 2020 at 08:39:52 UTC, tsbockman wrote: [...] You also get a deprecation message, about an integral promotion not being performed. I believe the result is correct and the warning can be ignored. So the warning is a bug? The deprecation message is a consequence of a (ve

Re: Checked!({short, ushort, byte, ubyte}, Throw): compilation fails

2020-04-18 Thread tsbockman via Digitalmars-d-learn
On Friday, 17 April 2020 at 21:25:34 UTC, kdevel wrote: A curiosity. Usually you cast into the type on the left. But Checked!(short, Throw) b = cast (Checked!(short, Throw)) a; does not compile: Error: template std.experimental.checkedint.Checked!(int, Throw).Checked.opCast cannot ded

Re: Checked!({short, ushort, byte, ubyte}, Throw): compilation fails

2020-04-18 Thread tsbockman via Digitalmars-d-learn
On Friday, 17 April 2020 at 21:25:34 UTC, kdevel wrote: On Friday, 17 April 2020 at 12:59:20 UTC, Simen Kjærås wrote: A curiosity. Usually you cast into the type on the left. But Checked!(short, Throw) b = cast (Checked!(short, Throw)) a; does not compile: Error: template std.experimenta

Re: Checked!({short, ushort, byte, ubyte}, Throw): compilation fails

2020-04-17 Thread kdevel via Digitalmars-d-learn
On Friday, 17 April 2020 at 12:59:20 UTC, Simen Kjærås wrote: [Deleted text makes sense] And assigning from an int to a short may discard data, so it's statically disallowed by Checked. This is a deliberate design choice, and the appropriate way to handle it is with a cast: unittest { im

Re: Checked!({short, ushort, byte, ubyte}, Throw): compilation fails

2020-04-17 Thread Simen Kjærås via Digitalmars-d-learn
On Friday, 17 April 2020 at 08:59:19 UTC, kdevel wrote: On Friday, 17 April 2020 at 04:29:06 UTC, Meta wrote: Unlike C/C++, char is not a numeric type in D; It's a UTF-8 code point: Thanks, it's a code /unit/. main reads now: void main () { bar!ubyte; bar!byte; bar!ushort; bar!sho

Re: Checked!({short, ushort, byte, ubyte}, Throw): compilation fails

2020-04-17 Thread kdevel via Digitalmars-d-learn
On Friday, 17 April 2020 at 04:29:06 UTC, Meta wrote: Unlike C/C++, char is not a numeric type in D; It's a UTF-8 code point: Thanks, it's a code /unit/. main reads now: void main () { bar!ubyte; bar!byte; bar!ushort; bar!short; bar!uint; bar!int; bar!ulong; bar!long; }