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



我有一个类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问题。

最新更新