在 C++ 中使用结构体构造函数创建结构体实例
我正在尝试围绕这次演讲进行思考:https://www.youtube.com/watch ?v=FXfrojjIo80 我在以下部分收到错误。这是简化版本。
template<typename... Ts>
struct parms : Ts... {};
template<typename... Ts>
parms(Ts... ) -> parms<Ts...>;
struct first{};
struct second{};
int main(int argc, char *argv[])
{
parms p(first{}, second{});
}
我在 clang 上遇到编译错误,但在 gcc 上编译。 clang 不支持哪个 C++ 功能?显然,如果我将 (
更改为 {
,它可以正常编译。
I am trying to wrap my mind around this talk: https://www.youtube.com/watch?v=FXfrojjIo80
I get an error on the following part. It is the simplified version.
template<typename... Ts>
struct parms : Ts... {};
template<typename... Ts>
parms(Ts... ) -> parms<Ts...>;
struct first{};
struct second{};
int main(int argc, char *argv[])
{
parms p(first{}, second{});
}
I get a compile error on clang but compiles on gcc. Which C++ feature is this that is not supported in clang? Obviously if i change the (
to {
it compiles fine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
cppReference aptly称其为“聚集体的括号初始化”。
Cppreference aptly calls it "Parenthesized initialization of aggregates".