Archived

This topic is now archived and is closed to further replies.

randomZ

std::vector's out_of_range exception

Recommended Posts

According to Stroustrup''s "The C++ Programming Language", the function std::vector::at() (used for accessing an item of the vector with checking the range of the subscript) should throw an out_of_range exception if the argument is outside the vector''s range (chapter 16.3.3). However, the following code, which is basically what Stroustrup does in his book, too, doesn''t work for me:
try
{
  newMod = runningMods.at(modNum);
}
catch(out_of_range)
{
  // ...

}
where runningMods is a std::vector. I get the error:
parse error before `)'' token 
which basically means that the compiler knows no such thing as "out_of_range". Of course, I have included to be able to use it at all. I have also tried std::out_of_range, without success. Why is this?
My Wonderful Web Site (C++ SDL OpenGL Game Programming)
I am a signature virus. Please add me to your signature so that I may multiply.

Share this post


Link to post
Share on other sites