QScopedArrayPointer Class
template <typename T, typename Cleanup> class QScopedArrayPointerQScopedArrayPointer クラスは、動的に割り当てられたオブジェクトの配列へのポインタを格納し、破棄時にその配列を削除します。詳細...
| ヘッダー: | #include <QScopedArrayPointer> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
| qmake: | QT += core |
| 継承元: | QScopedPointer |
注:このクラスのすべての関数は再入可能です。
パブリック関数
| QScopedArrayPointer() | |
| QScopedArrayPointer(D *p) | |
| ~QScopedArrayPointer() | |
| T & | operator[](qsizetype i) |
| const T & | operator[](qsizetype i) const |
詳細な説明
QScopedArrayPointer は、デフォルトで delete[] 演算子を使用して、それが指すオブジェクトを削除するQScopedPointer です。テンプレートパラメータT は配列要素の型を指定し、オプションのパラメータCleanup はクリーンアップハンドラを指定します。また、利便性のために演算子 [] も備えているため、次のように記述することができます。
void foo()
{
QScopedArrayPointer<int> i(new int[10]);
i[2] = 42;
...
return; // our integer array is now deleted using delete[]
}メンバ関数のドキュメント
QScopedArrayPointer::QScopedArrayPointer()
QScopedArrayPointer のインスタンスを作成します。
[explicit] template <typename D, QScopedArrayPointer<T, Cleanup>::if_same_type<D> = true> QScopedArrayPointer::QScopedArrayPointer(D *p)
QScopedArrayPointer を生成し、p が指すオブジェクトの配列を格納します。
[default] QScopedArrayPointer::~QScopedArrayPointer()
QScopedArrayPointer のインスタンスを破棄します。
T &QScopedArrayPointer::operator[](qsizetype i)
スコープ付きポインタが指すオブジェクトの配列内のエントリ `i ` へのアクセスを提供します。
含まれるポインタが `nullptr` である場合、動作は未定義となります。
注: Qt 6.5 以前のバージョンでは 、i の型はqsizetype ではなくint であったため、64 ビットプラットフォームで切り捨てが発生する可能性がありました。
isNull()も参照してください 。
const T &QScopedArrayPointer::operator[](qsizetype i) const
スコープ付きポインタが指すオブジェクト配列の、i というエントリへのアクセスを提供します。
含まれるポインタがnullptr である場合、動作は未定義となります。
注: Qt 6.5 以前のバージョンでは 、i の型はqsizetype ではなくint であったため、64 ビットプラットフォームで切り捨てが発生する可能性がありました。
isNull()も参照してください 。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.