Is there any way to do a left shift of bit's, and add a space?
Using the least number of operations in c or c++.

⚡ My resolution
I did not specify that my necessity was a static operation, and it was not onerous to have to operate dynamically.
In this case I opted for a compiler macro.
#define EXPAND_2(bitmask) ( ((bitmask & 0x0001) << 1) | /* Bit 0 expand */ \
((bitmask & 0x0002) << 2) | /* Bit 1 expand */ \
((bitmask & 0x0004) << 3) | /* Bit 2 expand */ \
((bitmask & 0x0008) << 4) | /* Bit 3 expand */ \
((bitmask & 0x0010) << 5) | /* Bit 4 expand */ \
((bitmask & 0x0020) << 6) | /* Bit 5 expand */ \
((bitmask & 0x0040) << 7) | /* Bit 6 expand */ \
((bitmask & 0x0080) << 8) | /* Bit 7 expand */ \
((bitmask & 0x0100) << 9) | /* Bit 8 expand */ \
((bitmask & 0x0200) << 10) | /* Bit 9 expand */ \
((bitmask & 0x0400) << 11) | /* Bit 10 expand */ \
((bitmask & 0x0800) << 12) | /* Bit 11 expand */ \
((bitmask & 0x1000) << 13) | /* Bit 12 expand */ \
((bitmask & 0x2000) << 14) | /* Bit 13 expand */ \
((bitmask & 0x4000) << 15) | /* Bit 14 expand */ \
((bitmask & 0x8000) << 16) /* Bit 15 expand */ \
)
the solution is used to set the pinmode registers of an STM32 where every 2 bits describes the configuration of a pin of the mcu.
thanks anyway even if the post has been closed.