generating all possible combinations of two data type

If i have 2 integers and 2 bool variables in a function and I want to generate all possible values and input all these values to a function. I want to seek help in generating all possible values of variables? the generated values would be like that. First two values are Boolean type variables and third and forth are int type ranged 0-2^16. The number of variables of any types can vary in this case they are 4.
0 0 0 0
0 0 0 1
0 0 0 2
. . . .
. . . .
0 0 0 65536
0 0 1 0
. . . .
. . . .
0 0 1 65536
0 1 2 0
. . . .
0 1 65536 65536
1 0 0 0
1 0 . .
1 0 65536 65536
1 1 65536 65536
You can try something on the following lines but given that the # of possible combinations is 2^36 (2 * 2 * 2^16 * 2^16), I'm not sure how long it's going to take. Also I'm replacing the bool with int {0, 1} to run the loops below:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

#include <iostream>
#include <vector>
using namespace std;

ret-type foo( int& i, int& j, int& k, int& l); //function declaration; 

const int vec_size = 68719476736 // ==2^36//

int main(){

vector <ret-type> v; // v stores the function results, so it's type parameter is == <ret-type>
v.reserve(vec_size); // reserves the vector memory first; 

for (int i = 0; i < 2; i++){
	for (int j = 0; j < 2; j++){
		for (int k = 0; k < 2^16; k++){
			for (int l = 0; l < 2^16; l++){
				v.push_back(foo(i, j, k, l));		
				} // close l-loop
			} // close k-loop
		} // close j-loop
	}// close i-loop
}

retn-type foo(){ //function definition

...}


Edit: having written all of the above I also started wondering how important it is for you to retain the 2 different data types. If that is critical, since there are 4 possible combinations of the 2 bools, you could have 4 sub-routines on the above lines, one for each of the 4 combinations
Last edited on
Topic archived. No new replies allowed.