我们可以在函数内声明函数(我想要一个局部变量,但它作为函数声明解析):
struct bvalue;
struct bdict {
bdict(bvalue);
}
struct bvalue {
explict operator bdict() const;
}
struct metainfo {
metainfo(bdict);
}
void foo(bvalue v) {
metainfo mi(bdict(v)); // parses as function declaration
metainfo mi = bdict(v); // workaround
// (this workaround doesn't work in the presence of explicit ctors)
}
Run Code Online (Sandbox Code Playgroud)
唯一的原因是"因为它使解析器变得更简单"和"因为标准是这样说的",还是有一个不明确的用途?