私は Visual Studio 2008 C++ アプリケーションを使用しており、std::vector. しかし、私は問題に遭遇しました。私の実装は、リソースへのハンドルを所有するアロケータに依存しています。この機能を使用する場合rebind、ハンドルの所有権を新しいアロケーターに譲渡する必要があります。このようなもの:
template< class T >
class MyAllocator
{
public:
    template< class U >
    explicit MyAllocator( const MyAllocator< U >& other ) throw() 
        :  h_( other.Detach() ) // can't do this to a `const`
    {
    };
    // ...
private:
    HANDLE Detach()
    {
        HANDLE h = h_;
        h_ = NULL;
        return h;
    };
    HANDLE h_;
}; // class MyAllocator
残念ながら、古いアロケーターのハンドル所有権を解放することはできませんconst。rebind コンストラクターから削除するconstと、コンテナーはそれを受け入れません。
error C2558: class 'MyAllocator<T>' : no copy constructor available or copy constructor is declared 'explicit'
この問題を回避する良い方法はありますか?