Works fine for me... Are you using a C++11 compiler? If so are you using codeblocks? If so I have had this happen to me a few times when I use the same project for multiple things (Mainly writing up code for here). Cleaning the build might work if not try creating a new project and then recompiling.
copy_if is a C++11 addition, it's likely that your development environment isn't configured for C++11 or is just too old.
Here's your program in C++11 mode: http://ideone.com/oJ0eOP
Here's your program in C++98 mode: http://ideone.com/KqgtYH