LoginSignup
1
0

More than 5 years have passed since last update.

ライブラリにtemplate関数が入っている場合のリンクエラーの対処

Last updated at Posted at 2013-07-31

以下の関数がライブラリに含まれているとする。

template <typename T>
void hoge(T h);

テンプレート関数がライブラリに含まれている場合、ライブラリがリンク先でどのような型でこの関数が使われるかわからないため、リンクに失敗する。
ライブラリ内に以下のように宣言することで解決する。
例:double型で使用。

template <typename T>
void hoge(T h);

template void hoge(double h);
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0