Quote Originally Posted by itsmeandnobodyelse View Post
The vector already holds an internal 16-byte elements array.

If you do

Code:
     unsigned char * p = (unsigned char *)&v[0];
     some_otherfunction_expecting_a_16bytes_array(p);
where v is one of the permutations you got the pointer p would point to a 16-elements array.

If you want to copy the array to fixed-sized char array, you would/could do

Code:
     unsigned char arr[16] = { '\0' };
     unsigned char * p = (unsigned char *)&v[0];
     memcpy(arr, p, min(sizeof(arr), v.size() * sizeof(v[0])));
The min is only to make sure that the vector really has 16 elements of type char, same as the arr.

Regards, Alex
That is all very true, but the problem remains that if you store bytes inside the vector, when you call next_permutation, you will be per mutating bytes, and not bits. Sure, you can recover the chars easily, but they won't be properlly shifted

A good solution would have been to use a vector<bool>, as it stores bit(-like) objects. This would work perfectly if you could write &v[0] on a vector bool, but you can't (at least not to my knowledge).

IMO, it's a lose-lose situation, where you have to get creative and daisy chain several solutions.