2

最近、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;
    };

C1001 エラーを回避するには、VS2013 をどのように構成するか、前述のコードを書き直しますか?

よろしくお願いいたします。

4

1 に答える 1

1

ICE は常にコンパイラのバグです。Microsoft にバグを報告してください (また、 VS2015 RC を実行するhttp://webcompiler.cloudapp.net/で再現できるかどうか試してみてください)。

std::tuple_cat任意の数のタプル (型と値の両方) を効率的に連結できる必要があるため、実装するのは難しいです。ただし、2 つの型を連結するだけであれば、複雑な機構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

于 2015-06-11T00:42:06.617 に答える