The following is the code:
#include <vector>
#include <string>
std::vector<std::string> zip(
const std::vector<std::string> & a,
const std::vector<std::string> & b) {
std::vector<std::string> result;
for (int i = 0; ; ++i) {
bool a_indexable = i < static_cast<int>(a.size()); //I couldn't get what the following two lines mean as I asked in the title, I couldn't get what bool means here and I couldn't get what i < static_cast<int>(a.size()) means here
bool b_indexable = i < static_cast<int>(b.size());
if (!a_indexable && !b_indexable) {
break;
}
std::string element;
if (a_indexable) {
element += a[i];
}
if (b_indexable) {
element += b[i];
}
result.push_back(element);
}
return result;
}
I know what static_cast<int>
means in the code but I feel confused about its combination especially like i < static_cast<int>(b.size())
. Please explain it if you could help me.