2016-04-14 345 views
0

我有一个类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)或使用MSVC2015

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

,这工作完全正常,但用gcc-4.9.3,我得到的错误:

error: cannot pass objects of non-trivially-copyable type const geodeticTuple {aka const struct std::tuple<unit, unit, unit>} through ...

而且由于GCC-4.9 .3不支持is_trivially_xxx风格类型特征,我很难理解为什么这是失败的。

是一个不平凡的类型的元组不平凡复制?

+0

为什么你使用旧式c vararg函数而不是可变参数函数模板? –

+0

我遇到了麻烦,因为当没有参数存在时它似乎不喜欢。 –

回答

1

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

由于该标准不需要繁琐的可复制性,实施者是否需要额外提供该担保(这将需要添加额外的专业化),这是一个QoI问题。

相关问题