Re: Casting Structs

2014-06-01 Thread Timon Gehr via Digitalmars-d-learn
On 06/01/2014 09:59 AM, Philippe Sigaud via Digitalmars-d-learn wrote: On Sun, Jun 1, 2014 at 12:34 AM, Timon Gehr via Digitalmars-d-learn wrote: This behaviour is independent of templates. Struct values of the same size can be reinterpret-cast to each other this way even if their types are co

Re: Casting Structs

2014-06-01 Thread Philippe Sigaud via Digitalmars-d-learn
On Sun, Jun 1, 2014 at 12:34 AM, Timon Gehr via Digitalmars-d-learn wrote: > This behaviour is independent of templates. Struct values of the same size > can be reinterpret-cast to each other this way even if their types are > completely unrelated. Do you know if this is by design?

Re: Casting Structs

2014-05-31 Thread Paul D Anderson via Digitalmars-d-learn
On Saturday, 31 May 2014 at 22:34:45 UTC, Timon Gehr wrote: On 06/01/2014 12:25 AM, Ali Çehreli wrote: dec10 little = cast(dec10(bingo)); You meant cast(dec10)(bingo). assert(little == dec10("123.45")); Is this expected behavior? Paul That is surprising. I've discovered that if the tem

Re: Casting Structs

2014-05-31 Thread Timon Gehr via Digitalmars-d-learn
On 06/01/2014 12:25 AM, Ali Çehreli wrote: dec10 little = cast(dec10(bingo)); You meant cast(dec10)(bingo). assert(little == dec10("123.45")); Is this expected behavior? Paul That is surprising. I've discovered that if the template has members that depend on a template parameter than th

Re: Casting Structs

2014-05-31 Thread Ali Çehreli via Digitalmars-d-learn
On 05/31/2014 02:11 PM, Paul D Anderson wrote: I'm working on the decimal number package for D. A decimal is a struct with precision, max exponent and rounding mode parameters: "Decimal!(PRECISION, MAX_EXPO, ROUNDING)". I was trying to overload the opCast operator for this struct and I found that

Casting Structs

2014-05-31 Thread Paul D Anderson via Digitalmars-d-learn
I'm working on the decimal number package for D. A decimal is a struct with precision, max exponent and rounding mode parameters: "Decimal!(PRECISION, MAX_EXPO, ROUNDING)". I was trying to overload the opCast operator for this struct and I found that it does not seem necessary. I can cast decim