Throw a specific exception from operator<<()

The operator `<<` now throws std::invalid_argument instead of using
just a `throw` statement. Using a `throw` statement outside of a catch
block results in call to `terminate` without giving the user any option
to recover (see http://stackoverflow.com/a/2692105/1062948). Throwing a
specific exception allows the user to decide how they want to handle
this situation.