
Untitled
By: a guest on
Aug 12th, 2012 | syntax:
None | size: 0.45 KB | hits: 5 | expires: Never
how to check a value exists in a c stl vector and apply a function to every element of the vector?
#include <vector>
#include <algorithm>
class apply_me
{
int multiplicator_;
public:
apply_me(const int multiplicator) : multiplicator_(multiplicator)
{};
int operator ()(const int element) const
{
return element*multiplicator_;
};
};
int main()
{
std::vector<int> v;
std::transform(v.begin(), v.end(),v.begin(), apply_me(3));
}