问题标签 [braced-init-list]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
60 浏览

c++ - 将大括号初始化程序完美转发给构造函数?

有类似的问题,但似乎没有一个是这样的。

我有一个存在的包装类来保存S. 以最简单的形式,我们有

当我打电话时,这似乎有效WrappedSSimple({1,2})。但是,我想让 c'tor 私有并具有静态工厂功能。那失败了:

https://godbolt.org/z/rsWK94Thq

有没有办法通过static make函数完美地转发大括号?