write all possible values of an array

What is an elegant way to write all possible values of an array? Let's say that the array is boolean:

bool A[3];

I'm trying to generate all possible values of this array: (0,0,0), (0,1,0), (0,0,1), (0,1,1), (1,0,0), (1,1,0), (1,0,1), (1,1,1). (Permutations with replacement, I believe)

Obviously, the number of possible values is K^n, where K is the number of possible values for each member of the array (2 for boolean, 10 for digits, etc.), and n is the length of the array. How do I make sure I cover all of them?
Last edited on
The algorithm library has methods for generating permutations.
Specifically the example given here http://www.cplusplus.com/reference/algorithm/next_permutation/
This isn't a permutation, though. It's treating an array as a number and iterating through all its possible states.
Topic archived. No new replies allowed.