2

Visual Studio 2013 で内部コンパイラ エラーが発生しました。正確なエラーは次のとおりです。

c:\program files (x86)\microsoft visual studio 12.0\vc\include\xmemory0(487): fatal error     C1001: An internal error has occurred in the compiler.
2>  (compiler file 'f:\dd\vctools\compiler\utc\src\p2\ehexcept.c', line 1483)
2>   To work around this problem, try simplifying or changing the program near the locations listed above.

これは、std::allocator_traits の実装でこのコードを示しています。

static _Alloc select_on_container_copy_construction(
    const _Alloc& _Al)
    {   // get allocator to use
    return (_Alloc_select::_Fn(0, _Al));
    }

そのことから、問題はカスタムアロケーター用に作成した実装に関連していると思います。このアロケーターは、私のプロジェクトで使用し、標準に準拠していない単純なアロケーターをラップするためのクラス テンプレートです (したがって、ラッピングが必要です)。ラッパーは次のとおりです。

template<class BaseAlloc_, class T_>
    class StdAllocator : public BaseAlloc_ {
    public:
        // Public types
        typedef T_              value_type;
        typedef T_*             pointer;
        typedef const T_*       const_pointer;
        typedef T_&             reference;
        typedef const T_&       const_reference;
        typedef std::size_t     size_type;
        typedef std::ptrdiff_t  difference_type;

    public:
        // Convert an allocator<T_> to allocator<U_>
        template<typename U_>
        struct rebind {
            typedef StdAllocator<BaseAlloc_,U_> other;
        };

    public:
        inline explicit StdAllocator():BaseAlloc_() {}
        inline explicit StdAllocator(BaseAlloc_ _b) :BaseAlloc_(_b) {}
        inline ~StdAllocator() {}
        inline explicit StdAllocator(StdAllocator const& _x) :BaseAlloc_(_x) {}
        template<typename U>
        inline explicit StdAllocator(StdAllocator<BaseAlloc_,U> const&) :BaseAlloc_() {}

        //    address
        inline pointer address(reference r) { return &r; }
        inline const_pointer address(const_reference r) { return &r; }

        //    memory allocation
        inline pointer allocate(size_type _cnt,
            typename std::allocator<void>::const_pointer = 0) {
            return BaseAlloc_::allocate<T_>(_cnt);
        }
        inline void deallocate(pointer _p, size_type _cnt) {
            BaseAlloc_::deallocate(_p,_cnt);
        }

        //    size
        inline size_type max_size() const {
            return std::numeric_limits<size_type>::max() / sizeof(T_);
        }

        //    construction/destruction
        inline void construct(pointer p, const T_& t) { new(p)T_(t); }
        inline void destroy(pointer _p) { 
            _p; // Work around for visual studio incorrect warning
            _p->~T_();
        }

        inline bool operator==(StdAllocator const&) { return true; }
        inline bool operator!=(StdAllocator const& a) { return !operator==(a); }
    };

Visual Studio がそれ以上の情報を提供しないことを考えると、この問題に取り組む方法がわかりません。

4

1 に答える 1

1

私はこれとリンクされた記事を読んだだけで、30 分後に 1 つのコメントがこの質問に答えていることわかりまし。 " それは私のためにトリックをしました。盗むのではなく、公開するために回答にコピーしました。

于 2016-03-30T08:22:46.997 に答える