这不编译:
class foo
{
struct node
{
wchar_t val;
unordered_map<wchar_t,unique_ptr<node>> children;
};
node root;
public:
foo() :
root.val(L'า'), // error: expected '(' or '}'
root.children(unordered_map<wchar_t, unique_ptr<node>>())
{}; // error: expected '(' or '}'
};
但这确实:
class foo
{
...<same as above> ....
foo() : root{L'า', unordered_map<wchar_t, unique_ptr<node>>()}{};
};
请赐教,为什么我不能像前者那样表达?我找了一个多小时,找不到解释。我确定我忽略了一些简单的事情。
clang 版本 9.0.0 (tags/RELEASE_900/final) 目标:x86_64-apple-darwin17.7.0 clang++ -std=c++17
谢谢!