我最近将一段C++代码从VS2012迁移到了VS2013。代码在VS2012下编译,但VS2013抛出C1001内部编译器错误。
具体而言,该错误指向std库中的tuple.h文件:
template<class... _Types1,
class _Kx_arg,
size_t... _Ix,
size_t _Ix_next,
class... _Types2,
class... _Rest>
struct _Tuple_cat2<tuple<_Types1...>, _Kx_arg, _Arg_idx<_Ix...>, _Ix_next,
tuple<_Types2...>, _Rest...>
: _Tuple_cat2<
tuple<_Types1..., _Types2...>,
typename _Cat_arg_idx<_Kx_arg,
typename _Make_arg_idx<_Types2...>::type>::type,
_Arg_idx<_Ix..., _Repeat_for<_Ix_next, _Types2>::value...>,
_Ix_next + 1,
_Rest...>
{ // determine tuple_cat's return type and _Kx/_Ix indices
};我的代码调用std::tuple_cat方法来检索连接的元组的类型(注意使用void类型的部分专门化):
template <typename TupleA, typename TupleB>
struct tuple_concatenator//yields the type of two concatenated tuples.
{
typedef decltype(std::tuple_cat(std::declval<TupleA>(),
std::declval<TupleB>())) type;
};
template <typename TupleA>
struct tuple_concatenator<TupleA, void>//yields the type of TupleA.
{
typedef TupleA type;
};
template <typename TupleB>
struct tuple_concatenator<void, TupleB>//yields the type of TupleB.
{
typedef TupleB type;
};
template <>
struct tuple_concatenator<void, void>
{
typedef void type;
};如何配置VS2013或重写上述代码以避免C1001错误?
提前感谢您的帮助。
发布于 2015-06-11 08:42:07
ICE始终是一个编译器错误。向微软提交一个bug (同时,试着在运行VS2015 RC的http://webcompiler.cloudapp.net/上重现它)。
std::tuple_cat很难实现,因为它需要能够有效地连接任意数量的元组-包括类型和值。但是,如果您只需要连接两个std::tuple<...>类型,则不需要复杂的tuple_cat机制;它很简单:
template <typename TupleA, typename TupleB>
struct tuple_concatenator;
template <class... Ts, class... Us>
struct tuple_concatenator<std::tuple<Ts...>, std::tuple<Us...>>
{
typedef std::tuple<Ts..., Us...> type;
};这应该可以很好地与您现有的void部分和完全专业化认证配合使用。
https://stackoverflow.com/questions/30769409
复制相似问题