ベクトルのポインタをAオブジェクトのベクトルに移動したい(this)。私は私のヘルプベクトル(mergesort用)を使用しているので、元のベクトルのヘルプベクトルの値が必要なので、これを行いたいと思います。しかし、私は1つの操作だけを使用したい(したがって、それは移動で実行され、要素のコピーは行われません)。C++でベクトルの派生クラスへのポインタを移動しますか?
これは私が使用するコードです:
template<class T>
class A:public vector<T> {
public:
void fillAndMove();
vector<T> help;
}
template<class T>
void A<T>:fillAndMove() {
// Fill a help array with random values
help.resize(2);
help[0] = 5;
help[1] = 3;
// This line doesn't work
*this = move(help);
}
私はエラーを以下の取得:
no match for 'operator=' (operand types are 'A<int>' and 'std::remove_reference<std::vector<int, std::allocator<int> >&>::type {aka std::vector<int, std::allocator<int> >}')
私は問題は、ヘルプベクトルがクラスAのオブジェクトにキャストする必要があることだと思うけど私はそれをどうすればいいのか分かりません。私を助けることができる人?
ありがとう、それは私が必要としていたものです! –