入力データの一括読み込み方法には、Hashtable
という名前のクラスがあります。これらのメソッドのそれぞれは、テンプレートを使用して異なるファイル形式をサポートし、文字列(filename)またはパーサオブジェクトを最初の引数として呼び出すことができるようにオーバーロードされています。オーバーロードされたテンプレート関数をインスタンス化できません
ここは例です。 consume_seqfile
メソッドは、そのようにクラスヘッダに定義されています。
template<typename SeqIO>
void consume_seqfile(
std::string const &filename,
unsigned int &total_reads,
unsigned long long &n_consumed
);
template<typename SeqIO>
void consume_seqfile(
read_parsers::ReadParserPtr<SeqIO> &parser,
unsigned int &total_reads,
unsigned long long &n_consumed
);
次に、クラス定義ファイルの最下部でインスタンス化されます。
template void Hashtable::consume_seqfile<FastxReader>(
std::string const &filename,
unsigned int &total_reads,
unsigned long long &n_consumed
);
template void Hashtable::consume_seqfile<FastxReader>(
ReadParserPtr<FastxReader>& parser,
unsigned int &total_reads,
unsigned long long &n_consumed
);
これはすべて正常に動作し、数ヶ月間あります。私は今、追加の引数を持つこのメソッドの新しい変種を追加しようとしています。それはヘッダーのように定義されています。
template<typename SeqIO>
void consume_seqfile_with_mask(
std::string const &filename,
Hashtable* mask,
unsigned int &total_reads,
unsigned long long &n_consumed
);
template<typename SeqIO>
void consume_seqfile_with_mask(
read_parsers::ReadParserPtr<SeqIO>& parser,
Hashtable* mask,
unsigned int &total_reads,
unsigned long long &n_consumed
);
ソースファイルでインスタンス化されています。
template void Hashtable::consume_seqfile_with_mask<FastxReader>(
std::string const &filename,
Hashtable* mask,
unsigned int &total_reads,
unsigned long long &n_consumed
);
template void Hashtable::consume_seqfile_with_mask<FastxReader>(
ReadParserPtr<FastxReader>& parser,
Hashtable* mask,
unsigned int &total_reads,
unsigned long long &n_consumed
);
ただし、コンパイルしようとすると、次のエラーメッセージが表示されます。
src/oxli/hashtable.cc:635:26: error: explicit instantiation of undefined function template 'consume_seqfile_with_mask'
template void Hashtable::consume_seqfile_with_mask<FastxReader>(
^
include/oxli/hashtable.hh:281:10: note: explicit instantiation refers here
void consume_seqfile_with_mask(
私のGoogle/StackOverflowのスキルが失敗しています。この問題の原因は何でしょうか?
更新日:コードは表示されていませんでした。 I には関数定義がありましたが、名前空間には適切なHashtable::
接頭辞がありませんでした。だから...関数は実際には定義されていませんでした。名前空間を適切に組み込むことによって解決される問題。
はい、いいえ。アップデートを参照してください。関数が定義されましたが、私は誤って名前空間を省略しました。それを記入して問題を解決してください。 –