namespace std {
template<class T> unique_ptr<T> make_unique_for_overwrite(); // (1)
template<class T> unique_ptr<T> make_unique_for_overwrite(size_t n); // (2)
template<class T, class... Args> unspecified make_unique_for_overwrite(Args&&...) = delete; // (3)
}
概要
unique_ptr
オブジェクトを構築する。その際、型T
のオブジェクトはデフォルト構築される。
- (1) :
T
が配列型でないときに選択される。 - (2) :
T
が不明な境界の配列のときに選択される。 - (3) : 許可されていないオーバーロードとして宣言される。
T
は既知の境界の配列型である。
戻り値
- (1) :
unique_ptr<T>(new T())
- (2) :
unique_ptr<T>(new remove_extent_t<T>[n]())
例
#include <iostream>
#include <memory>
#include <utility>
int main()
{
std::unique_ptr<std::pair<int, int>> p1 = std::make_unique_for_overwrite<std::pair<int, int>>();
std::cout << p1->first << ':' << p1->second << std::endl;
}
出力
0:0
バージョン
言語
- C++20
処理系
- Clang: 10.0.0 現在未対応
- GCC: 10.0.0 現在未対応
- Visual C++: ??