throw operator

   
throw operator Throws an exception

  throw-expr  ::= throw [  assignment-expr  ] 

The throw operator throws assignment-expr as an exception. The throw expression has type void . With no operand, throw rethrows the current pending exception. If no exception is pending, terminate( ) is called.

Example

 template<typename C> typename C::value_type checked_first(const C& c) {   if (not c.empty(  ))     return c[0];  throw  std::out_of_range("container is empty"); } 

See Also

expression , try , Chapter 3, <exception> , <stdexcept>

   


C++ in a Nutshell
C++ in a Nutshell
ISBN: 059600298X
EAN: 2147483647
Year: 2005
Pages: 270
Authors: Ray Lischner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net