使用
T[]专业化:
std::unique_ptr<unsigned char[]> testData(new unsigned char[16000]());
请注意,在理想情况下,不必显式使用
new实例化
unique_ptr,从而避免了潜在的异常安全隐患。为此,C ++
14为您提供了
std::make_unique功能模板。有关更多详细信息,请参见此出色的GOTW。语法为:
auto testData = std::make_unique<unsigned char[]>(16000);



