我需要vector<unique<TNode>>用nullptrs 初始化a .这篇文章中的方法太复杂了.我的情况很特殊,因为我只需将其初始化为nullptr.我怎样才能实现它?
我知道我可以使用一个for循环到push_back一个nullptr各一次.有优雅的方式吗?
BTW,make_unqiue对我的编译器不起作用.
#include <iostream>
#include <memory>
#include <vector>
using namespace std;
struct TNode {
//char ch;
bool isWord;
vector<unique_ptr<TNode> > children;
TNode(): isWord(false), children(26,nullptr) {}
};
int main()
{
TNode rt;
return 0;
}
Run Code Online (Sandbox Code Playgroud)