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

履歴 編集

class
<new>

std::bad_array_new_length(C++11)

namespace std {
  class bad_array_new_length : public bad_alloc;
}

概要

動的に記憶域を確保しようとする配列の長さが 0 未満または処理系の最大値以上の場合に送出される例外

メンバ関数

名前 説明 対応バージョン
(constructor) コンストラクタ C++11
(destructor) デストラクタ C++11
operator= 代入演算子 C++11
what エラー理由を取得する C++11

#include <iostream>

int main() {
  int n = -1;
  try {
    int* p = new int[n];
    delete[] p;
  }
  catch (std::bad_array_new_length&) {
    std::cout << "bad array new length" << std::endl;
  }
}

出力例

bad array new length

バージョン

C++11

処理系