• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

    最終更新日時(UTC):
    が更新

    履歴 編集

    function
    <exception>

    std::nested_exception::コンストラクタ

    nested_exception() noexcept;                                  // (1)
    nested_exception(const nested_exception&) noexcept = default; // (2)
    

    nested_exceptionオブジェクトの構築

    例外

    投げない

    #include <exception>
    #include <iostream>
    
    class my_exception : public std::nested_exception {};
    
    int main()
    {
      try {
        try {
          throw 1;
        }
        catch (int& x) {
          my_exception e; // 現在の例外(int)が保持される
    
          // my_exceptionによって入れ子になった例外へのポインタを取得して再送出
          std::rethrow_exception(e.nested_ptr());
        }
      }
      catch (int& x) {
        std::cout << x << std::endl;
      }
    } 
    

    出力

    1
    

    バージョン

    言語

    • C++11

    処理系

    参照