i have a short question about an initialization that I don't fully understand.
About the code: I'm looking for pairs and my vector "vector temp" saves the places where my loop found a pair. after my Temp is filled with some values I check it to look where the pairs were found. I made 2 for loops to loop through the vector. Outer loop i and inner loop j. Temp stores the j value where a pair is found.
Now about my question, this is the code
`bool repeat = 1;
rep_check = find(repeat_check.begin(), repeat_check.end(), d_in[i]);
if( rep_check == repeat_check.end() ) repeat = 0;
else out.push_back(vector<int> (1,temp));`
What you are doing here is pushing back a
vector<int> in a container (I guess it is a vector) named
out. The constructor call is
vector<int> (1,temp) and it says that you want to construct a
vector<int> with size
1 and the vector elements (in this case only one) are initialized with the value of
The prototype of this vector constructor looks like:
explicit vector (size_type n, const value_type& val = value_type(), const allocator_type& alloc = allocator_type());
and the description is: Fill constructor: Constructs a container with n elements. Each element is a copy of val.