so something like bitswap<4>(pattern, 3,1,2,0) instead?

I didn't know bitswap existed, so I learned something 8-) Shows you what I know about c++.