変数std::deque<cv::Point[4]> pastpolygons
を参照渡しします。私はまた、C配列cv::Point polygon[4]
を同じ関数を参照して渡しています。 1つの機能が必要に応じて配列のdeque
に配列をプッシュ/ポップすることが意図されています。私はコードを書いたことがあると思います(コードを書くための他の方法はありますか?)、コンパイルエラーは非常に冗長で分かりにくいです(数ページです)。参照でdequeの修飾子を関数で呼び出すと、MinGW64コンパイルエラーが発生する
は、ここでは、コードです:
void AveragePolygon (cv::Point (*polygon)[4], std::deque<cv::Point[4]> *pastpolygons, int samplestokeep)
{
//FIFO
pastpolygons->push_back(*polygon); //comment and compiles fine
if (pastpolygons->size() > samplestokeep) {
pastpolygons->pop_front(); //comment and compiles fine
}
return;
}
パラメータと引数の構文は、特にトリッキーだったが、それは私がpastpolygons
の修飾子を呼び出すしようとしない限り、コンパイルします。私も(*pastpolygons).push_back/pop_front
を試してみましたが、無駄です。何か案は?
、コンパイルエラーの最初のビット:
C:/MinGW64/x86_64-w64-mingw32/include/c++/ext/new_allocator.h: In instantiation of 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = cv::Point_<int> [4]; _Args = {const cv::Point_<int> (&)[4]}; _Tp = cv::Point_<int> [4]]': C:/MinGW64/x86_64-w64-mingw32/include/c++/bits/alloc_traits.h:256:4: required from 'static std::_Require<typename std::allocator_traits<_Alloc>::__construct_helper<_Tp, _Args>::type> std::allocator_traits<_Alloc>::_S_construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp = cv::Point_<int> [4]; _Args = {const cv::Point_<int> (&)[4]}; _Alloc = std::allocator<cv::Point_<int> [4]>; std::_Require<typename s
「私は変数を渡すよ "スタンダード::両端キューpastpolygons":例えば
、以下執拗-C++コード11
4点を取るコンストラクタを定義します。 " - いいえ、違います。 – SergeyA
配列を標準コンテナに格納することはできません。 'std :: vector'や' std :: array'を使うことができます。そしてそれらは参考文献ではなく、指針です。 – molbdnilo