Am Fri, 22 Jul 2016 01:48:52 +
schrieb Rufus Smith :
> I would like to combine two types
>
>
> template Foo(A, B = 4)
> {
> union
> {
> byte b = B;
> int a = A << 8;
> }
> }
>
>
> I get an error about overlapping default initialization. They
> don't actually
On 07/21/2016 08:00 PM, Rufus Smith wrote:
>> Bitfields may actually be useful in this case:
>>
>> https://dlang.org/phobos/std_bitmanip.html#.bitfields
>>
>
> They don't allow default assignment though?
A factory function can help:
import std.bitmanip;
struct S(int a_init, byte b_init) {
On Friday, 22 July 2016 at 02:08:06 UTC, Ali Çehreli wrote:
On 07/21/2016 06:48 PM, Rufus Smith wrote:
> I would like to combine two types
>
>
> template Foo(A, B = 4)
> {
> union
> {
> byte b = B;
> int a = A << 8;
> }
> }
>
> This packs a and b together in to an i
On 07/21/2016 06:48 PM, Rufus Smith wrote:
> I would like to combine two types
>
>
> template Foo(A, B = 4)
> {
> union
> {
> byte b = B;
> int a = A << 8;
> }
> }
>
> This packs a and b together in to an int bytes, saving an int(rather
> than storing a and b in an i
I would like to combine two types
template Foo(A, B = 4)
{
union
{
byte b = B;
int a = A << 8;
}
}
This packs a and b together in to an int bytes, saving an
int(rather than storing a and b in an int each) and makes it
easier to access.
I get an error about overlapp