public static ref T gather <T>(T src, T mask, ref T dst) where T : unmanaged { if (typeof(T) == typeof(sbyte)) { Bits.gather(int8(src), int8(mask), ref int8(ref dst)); } else if (typeof(T) == typeof(byte)) { Bits.gather(uint8(src), uint8(mask), ref uint8(ref dst)); } else if (typeof(T) == typeof(short)) { Bits.gather(int16(src), int16(mask), ref int16(ref dst)); } else if (typeof(T) == typeof(ushort)) { Bits.gather(uint16(src), uint16(mask), ref uint16(ref dst)); } else if (typeof(T) == typeof(int)) { Bits.gather(int32(src), int32(mask), ref int32(ref dst)); } else if (typeof(T) == typeof(uint)) { Bits.gather(uint32(src), uint32(mask), ref uint32(ref dst)); } else if (typeof(T) == typeof(long)) { Bits.gather(int64(src), int64(mask), ref int64(ref dst)); } else if (typeof(T) == typeof(ulong)) { Bits.gather(uint64(src), uint64(mask), ref uint64(ref dst)); } else { throw unsupported <T>(); } return(ref dst); }
public static T gather <T>(T src, T mask) where T : unmanaged { if (typeof(T) == typeof(sbyte)) { return(generic <T>(Bits.gather(int8(src), int8(mask)))); } else if (typeof(T) == typeof(byte)) { return(generic <T>(Bits.gather(uint8(src), uint8(mask)))); } else if (typeof(T) == typeof(short)) { return(generic <T>(Bits.gather(int16(src), int16(mask)))); } else if (typeof(T) == typeof(ushort)) { return(generic <T>(Bits.gather(uint16(src), uint16(mask)))); } else if (typeof(T) == typeof(int)) { return(generic <T>(Bits.gather(int32(src), int32(mask)))); } else if (typeof(T) == typeof(uint)) { return(generic <T>(Bits.gather(uint32(src), uint32(mask)))); } else if (typeof(T) == typeof(long)) { return(generic <T>(Bits.gather(int64(src), int64(mask)))); } else if (typeof(T) == typeof(ulong)) { return(generic <T>(Bits.gather(uint64(src), uint64(mask)))); } else { throw unsupported <T>(); } }
public static uint select(uint src, Part12x6 part) => Bits.gather(src, (uint)part);
public static byte select(uint src, Part6x1 part) => (byte)Bits.gather(src, (uint)part);