動作環境
C++ Builder XE4
.get()
unique_ptrで作成した後で、そのポインタを関数などで渡す時の書き方。
std::unique_ptr<TStringList> fileList(new TStringList);
getFileList(fileList.get()); // 使用例
getFileList()の中で特定フォルダのファイルリストをfileListに格納する、など。
Note: 過去のある時期によく実装していた内容だが、その後、別の作業(Python, numpy, NetCDF, NCLなど)をしているうちに書き方を忘れました。。。備忘録として記事にします。
参考
本(Kindle)の記載
@ EFFECTIVE C++: 55 Specific Ways to Improve Your Programs and Designs
by Scott Meyers
68ページ目(/279ページ)
tr1::shared_ptr and auto_ptr both offer a get member function to perform an explicit conversion, i.e., to return (a copy of)the raw pointer inside the smart pointer object:
int days = daysHeld(pInv.get()); // find, passes the raw pointer
// in pInv to daysHeld