Have you checked out this link on Boost:
boost foreach[
^]
Otherwise, in your second entry, the foreach command needs a variable to receive the output from your container, as well as the instance of the container. You have declared a pair<> object pp to be the variable, and accept each value iterated in the vector aa.
If you want to modify the values in your vector, you would need to use a reference, &pp.