I need to initialize a vector<unique<TNode>> with nullptrs. The method in this post is too complicated. My situation is special since I only need to initialize it as nullptr. How can I achieve it?
I know I can use a for-loop to push_back a nullptr each time. Is there an elegant way?
BTW, make_unqiue does not work on my compiler.
#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;
}