繁体   English   中英

错误:无法通过`...`传递非平凡复制类型的对象

[英]error: cannot pass objects of non-trivially-copyable type through `…`

我有一个类unit ,它具有属性

std::is_trivial<unit>::value; // true
std::is_trivially_copyable<unit>::value; // true (on compilers which have this trait)

我想将unit向量作为元组传递,例如

using geodeticTuple = std::tuple<unit, unit, unit>;

我需要这些向量可传递给使用不同类型参数的转换函数,例如

someOtherType convert(const geodeticTuple& point, const geodeticTuple& origin)

someOtherType convert(const geodeticTuple& point, ...)

使用MSVC2015,这完全可以正常工作,但是对于gcc-4.9.3,我收到了错误消息:

错误:无法将非平凡可复制类型的对象const geodeticTuple {aka const struct std::tuple<unit, unit, unit>}传递给...

而且由于gcc-4.9.3不支持is_trivially_xxx样式的类型特征,所以我很难理解为什么会失败。

琐碎类型的元组不是琐碎可复制的吗?

tuple的复制/移动赋值运算符需要对引用类型进行特殊处理,因此在一般情况下,它们必须由用户提供。

由于该标准不要求琐碎的可复制性,因此实现者是否会花更多的时间提供保证(这将需要添加其他专业知识),这是一个QoI问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM