私はそのように宣言テンプレートクラスのメンバ関数があります。私はその行の変数が宣言されているC++テンプレートマッチングなしの関数呼び出し
frequencies.insert(frequencies.begin() + getPosition(frequencies, current, ascending),
frequencies[i]);
ラインで、このどこかを呼び出す
template <class T>
int Data<T>::getPosition(vector<T> stuff, T newStuff, bool ascending)
を次のようになります。
vector<T> temp;
vector<int> frequencies;
int current = frequency.find(words[i])->second;
ただし、getPosition
を呼び出すと、このエラーが発生します。
Data.h|158|error: no matching function for call to 'primitives::Data<double>::getPosition(std::vector<int, std::allocator<int> >&, int&, bool&)'|
Data.h|165|note: candidates are: int primitives::Data<T>::getPosition(std::vector<T, std::allocator<_CharT> >, T, bool) [with T = double]|
私はここで間違っていますか?
テンプレートパラメータTの取得方法が明確でないため、より多くのコンテキストを提供する必要があります。プリミティブ::データの別のメンバ関数から呼び出していますか? – Stewart
また、ベクトルを値渡しすることは望ましくないでしょう。それはベクトルをコピーしますが、はるかに効率的なconst refで渡すことができます。 – Stewart
@Stewartはいすべてコードはprimitives :: Dataクラスの内部にあります。また、提案に感謝します。代わりに – wrongusername