Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) std::length_error

 

std::length_error (a derived class from std::runtime_error) is thrown when a too big std::string is created.

 

#include <iostream>
#include <stdexcept>
#include <string>

int main()
{
  std::string s;
  try
  {
    s.resize(s.max_size()+1);
  }
  catch (std::length_error& e)
  {
    std::cout << e.what();
  }
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict