Merge sort アルゴリズムを実装しています。問題は、アルゴリズム内で自動的に推定された型のベクトルを使用しようとしたときです。
template <typename TIterator, typename TCompare>
void mergeSort(TIterator begin, TIterator end, TCompare criterium)
{
//...
auto help = *begin; // help is a value (not a reference)
QVector<decltype(help)> leftPart; // now decltype(help) is also a value
//... // and not a reference
}
これは機能します。
しかし、アルゴリズムをTIterators
定数参照で渡すと、人生で一度も経験したことのないエラーが発生します。
template <typename TIterator, typename TCompare>
void mergeSort(const TIterator& begin, const TIterator& end, TCompare criterium)
{
//...
auto help = *begin; // help is a value (not a reference)
QVector<decltype(help)> leftPart; // now decltype(help) is also a value
//...
}
結果:
In function 'void mergeSort(const TIterator&, const TIterator&, TCompare)':
internal compiler error: in type_unification_real, at cp/pt.c:14176
私は使用g++ 4.6.3
していますUbuntu
何が悪かったのか?