Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <iostream>
- #include <boost/foreach.hpp>
- int main()
- {
- std::string hello( "Hello, world!" );
- BOOST_FOREACH( char ch, hello )
- {
- std::cout << ch;
- }
- return 0;
- }
- for (int i = 0; i < some_vector.size(); i++)
- if (some_vector[i] == NULL) some_other_vector[i]++;
- int weighted_sum = 0;
- for (int i = 0; i < a_vector.size(); ++i) {
- weighted_sum += (i + 1) * a_vector[i]; // Just writing something a little nontrivial.
- }
- for (vector<Child>::iterator iter = children.begin();
- iter != children.end();
- ++iter)
- {
- iter->setFooCount(n);
- }
- for_each(children.begin(), children.end(), SetFooCount(n));
- class SetFooCount
- {
- public:
- SetFooCount(int n) : fooCount(n) {}
- void operator () (Child& child)
- {
- child.setFooCount(fooCount);
- }
- private:
- int fooCount;
- };
Add Comment
Please, Sign In to add comment