Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::unexpected

      From cppreference.com
      <cpp‎ |error
       
       
      Diagnostics library
       
      Defined in header<exception>
      void unexpected();
      (until C++11)
      [[noreturn]]void unexpected();
      (deprecated in C++11)
      (removed in C++17)

      std::unexpected() is called by the C++ runtime when adynamic exception specification is violated: an exception is thrown from a function whose exception specification forbids exceptions of this type.

      std::unexpected() may also be called directly from the program.

      In either case,std::unexpected calls the currently installedstd::unexpected_handler. The defaultstd::unexpected_handler callsstd::terminate.

      If a destructor reset the unexpected handler during stack unwinding and the unwinding later led tounexpected being called, the handler that was installed at the end of the throw expression is the one that will be called (note: it was ambiguous whether re-throwing applied the new handlers).

      (until C++11)

      If a destructor reset the unexpected handler during stack unwinding, it is unspecified which handler is called if the unwinding later led tounexpected being called.

      (since C++11)

      [edit]Exceptions

      Throw any exception thrown by the currently installedstd::unexpected_handler.

      [edit]Defect reports

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

      DRApplied toBehavior as publishedCorrect behavior
      LWG 2111C++11effect of callingstd::set_unexpected during stack
      unwinding differs from C++98 and breaks some ABIs
      made unspecified

      [edit]See also

      (C++23)
      represented as an unexpected value
      (class template)[edit]
      (deprecated in C++11)(removed in C++17)
      the type of the function called bystd::unexpected
      (typedef)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/error/unexpected&oldid=175326"

      [8]ページ先頭

      ©2009-2025 Movatter.jp