【发布时间】:2016-04-14 13:55:21
【问题描述】:
我有一个类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 样式类型特征,我无法理解为什么会失败。
平凡类型的元组是不可平凡复制的吗?
【问题讨论】:
-
为什么要使用旧式 c 可变参数函数而不是可变参数函数模板?
-
我遇到了麻烦,因为它似乎不喜欢没有参数存在的情况。
标签: c++ c++11 tuples typetraits stdtuple