I would like to create a vector
of pairs starting from a pair of vector
s. For example, if A
is std::vector A = [1 0 1]
and B
is std::vector B = [0 1 0]
, I want a structure std::vector C = [1 0, 0 1, 1 0]
where C_i = std::pair(A_i,B_i)
.
I would avoid for
loop through the two vector, so I'm looking for few lines code like std::transform()
.
I tried the following code:
std::vector<bool> boolPredLabel(tsLabels.size());
std::vector<bool> boolRealLabel(tsLabels.size());
std::vector<std::pair<bool,bool>> TrPrPair(tsLabels.size());
std::transform(boolRealLabel.begin(), boolRealLabel.end(), boolPredLabel.begin(), TrPrPair.begin(),std::make_pair());
This lead me to a compiler error:
error: no matching function for call to ‘make_pair()’
std::transform(boolRealLabel.begin(), boolRealLabel.end(), boolPredLabel.begin(), TrPrPair.begin(),std::make_pair());
...
note: candidate expects 2 arguments, 0 provided
std::transform(boolRealLabel.begin(), boolRealLabel.end(), boolPredLabel.begin(), TrPrPair.begin(),std::make_pair());
The message is clear, but I don't know what pass to the binary operator. I have to admit that I don't have a clear understanding of std::transform()
and I've just use it with functor.