首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >std::tuple_cat中的VS2013 C++ C1001错误

std::tuple_cat中的VS2013 C++ C1001错误
EN

Stack Overflow用户
提问于 2015-06-11 08:05:20
回答 1查看 314关注 0票数 2

我最近将一段C++代码从VS2012迁移到了VS2013。代码在VS2012下编译,但VS2013抛出C1001内部编译器错误。

具体而言,该错误指向std库中的tuple.h文件:

代码语言:javascript
复制
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类型的部分专门化):

代码语言:javascript
复制
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错误?

提前感谢您的帮助。

EN

回答 1

Stack Overflow用户

发布于 2015-06-11 08:42:07

ICE始终是一个编译器错误。向微软提交一个bug (同时,试着在运行VS2015 RC的http://webcompiler.cloudapp.net/上重现它)。

std::tuple_cat很难实现,因为它需要能够有效地连接任意数量的元组-包括类型和值。但是,如果您只需要连接两个std::tuple<...>类型,则不需要复杂的tuple_cat机制;它很简单:

代码语言:javascript
复制
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部分和完全专业化认证配合使用。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30769409

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档