translating shifts from Java (Processing) to C++ (arduino)

struct rgb_t
{
    union
    {
        struct {
            unsigned r:5;
            unsigned g:6;
            unsigned b:5;
        }
        uint16_t    rgb;
    }
};


rgb_t   rgb = { 1, 2, 3 };
int     r   = rgb.r;
int     g   = rgb.g;
int     b   = rgb.b;

'rgb_t' is the same size as an 'unsigned int', or 'uint16_t, on the Arduino.

rgb_t   rgb;

rgb.rgb = rgbPacked;

int     r   = rgb.r;
int     g   = rgb.g;
int     b   = rgb.b;