Condividi tramite


length_error Class

La classe funge da classe base per tutte le eccezioni generate per segnalare un tentativo di generare troppo lungo un oggetto per specificare.

class length_error : public logic_error {
public:
    explicit length_error(const string& message);
    explicit length_error(const char *message);
};

Note

Il valore restituito da exception Class è una copia messaggio.Scuro.

Esempio

// length_error.cpp
// compile with: /EHsc /GR /MDd
#include <vector>
#include <iostream>

using namespace std;

template<class _Ty>
class stingyallocator : public allocator<_Ty>
{
public:
   template <class U>
      struct rebind { typedef stingyallocator<U> other; };
   _SIZT max_size( ) const
   {
         return 10;
   };

};

int main( )
{
   try
   {
      vector<int, stingyallocator< int > > myv;
      for ( int i = 0; i < 11; i++ ) myv.push_back( i );
   }
   catch ( exception &e )
   {
      cerr << "Caught " << e.what( ) << endl;
      cerr << "Type " << typeid( e ).name( ) << endl;
   };
}
  

Requisiti

Header: <stdexcept>

Spazio dei nomi: deviazione standard

Vedere anche

Riferimenti

logic_error Class

Thread safety della libreria C++ standard