Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::exception::exception

      From cppreference.com
      <cpp‎ |error‎ |exception
       
       
      Utilities library
       
      Diagnostics library
       
       
      (1)
      exception()throw();
      (until C++11)
      exception()noexcept;
      (since C++11)
      (constexpr since C++26)
      (2)
      exception(const exception& other)throw();
      (until C++11)
      exception(const exception& other)noexcept;
      (since C++11)
      (constexpr since C++26)

      Constructs new exception object.

      1) Default constructor.what() returns an implementation-defined string.
      2) Copy constructor. Initializes the contents with those ofother. If*this andother both have dynamic typestd::exception thenstd::strcmp(what(), other.what())==0.

      [edit]Parameters

      other - another exception to assign the contents of

      [edit]Notes

      Because copyingstd::exception is not permitted to throw exceptions, when derived classes (such asstd::runtime_error) have to manage a user-defined diagnostic message, it is typically implemented as a copy-on-write string.

      The Microsoft implementation includes non-standard constructors taking strings thus allowing instances to be thrown directly with a meaningful error message. The nearest standard equivalents arestd::runtime_error orstd::logic_error.

      [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 is no requirement onwhat() of the exception copyadded
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/error/exception/exception&oldid=177843"

      [8]ページ先頭

      ©2009-2025 Movatter.jp