Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::exception

      From cppreference.com
      <cpp‎ |error
       
       
      Utilities library
       
      Diagnostics library
       
       
      Defined in header<exception>
      class exception;

      Provides consistent interface to handle errors through thethrow expression.

      All exceptions generated by the standard library inherit fromstd::exception.

      All member functions ofstd::exception areconstexpr.

      (since C++26)

      Contents

      [edit]Member functions

      constructs the exception object
      (public member function)
      [virtual]
      destroys the exception object
      (virtual public member function)[edit]
      copies exception object
      (public member function)[edit]
      [virtual]
      returns an explanatory string
      (virtual public member function)[edit]

      [edit]Standard exception requirements

      Each standard library classT that derives fromstd::exception has the following publicly accessible member functions, each of themdo not exit with an exception(until C++11)having anon-throwing exception specification(since C++11):

      The copy constructor and the copy assignment operator meet the following postcondition:

      • If two objectslhs andrhs both have dynamic typeT andlhs is a copy ofrhs, thenstd::strcmp(lhs.what(), rhs.what()) is equal to0.

      Thewhat() member function of each suchT satisfies the constraints specified forstd::exception::what().

      [edit]Standard exceptions

      (since C++11)
      (since C++11)
      (since C++17)
      (TM TS)
      (since C++20)
      (since C++17)
      (since C++23)
      (since C++11)
      (since C++11)
      (until C++11)
      (since C++17)

      [edit]Notes

      Feature-test macroValueStdFeature
      __cpp_lib_constexpr_exceptions202411L(C++26)constexpr for exception types

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

      DRApplied toBehavior as publishedCorrect behavior
      LWG 471C++98there was no requirement on standard library classes derived fromstd::exceptionadded
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/error/exception&oldid=183008"

      [8]ページ先頭

      ©2009-2025 Movatter.jp