Would someone kindly explain what this line of code does in detail? Please elaborate on the parameters that the function takes in. What else is commonly used as parameters for this function? Does the copy_if function only work with vectors? I am particularly confused about the last part after the 3rd comma " [] (int x) {return x % 2; "...
Here is the line of code I do not understand >>>>>>>>>>>>>>>>>>>>>>>>>>> std::copy_if(array.begin(), array.end(), std::back_inserter(odds), [] (int x) {return x % 2;});
I understand that it copies from array (which is a vector), and "back inserts" into the vector odds.
Further,whenever I searched for an explanation through google, it's taken me to websites that have rather vague explanations. Either, would someone please teach me how to understand their gibberish, or would you point me to a reliable source to learn these kinds of things? For example, this link describes a while loop and unary predicate and I'm just lost.
Aucun commentaire:
Enregistrer un commentaire