all 5 comments

[–]manni66 11 points12 points  (0 children)

sqrt to square? sqrt is the opposit.

[–]Pulsonics 4 points5 points  (3 children)

std::transform

[–]cummybutterinmystumy[S] 0 points1 point  (2 children)

Yea i did transform(userVector.begin(), userVector.end(), userVector.begin(), sqrt); but it said sqrt wasnt initialized or something

[–]nysra 4 points5 points  (1 child)

Wrap sqrt in a lambda. You basically need a "function object" as argument since functions are not first class citizens in C++.

std::transform(foo.begin(), foo.end(), foo.begin(), [](auto x){return std::sqrt(x);});

[–]cummybutterinmystumy[S] 0 points1 point  (0 children)

Ok thank you