The users could be prompted to enter eof (control + Z on Windows, control + D on UNIX) when they're done. That would cause a while(std::cin >> a) loop to break.
Well, if you mean all the values are inputted at once (in one go), then it's relatively easy. Catch the values as a string and then convert them to numbers until the end of the string.
The problem is that the numbers are read from stdin(keyboard by default). when I run the executable, I need to be able to redirect stdin to a file, so it needs to work with keyboard input or from a file. I just need to keep reading integers until I hit a newline.