The classics are always passed-Exception Handling: A False Sense of Security

链接:
Exception Handling: A False Sense of Security
– C++ Report, Tom Cargill, Vol.6, No.9, November-December 1994

  1. Argument expressions are fully evaluated before their function is called.
    v[top–], top has been decremented before calling the copy construct return statement. Code:

     template 
    T Stack::pop()
    {
          
          
      if( top < 0 )
        throw ""pop on empty stack"";
      return v[top--]; // throw
    }
    
  2. Don't worry about new exceptions, except catching bad_alloc exceptions and logging (the memory has to be enough). There is no good way, right? ? ?

Guess you like

Origin blog.csdn.net/alpha_007/article/details/115063839