単純な (非テンプレート) クラスを作成しているときに、関数の実装が「その場で」提供されている場合、それは自動的に として扱われinline
ます。
class A {
void InlinedFunction() { int a = 0; }
// ^^^^ the same as 'inline void InlinedFunction'
}
テンプレートベースのクラスについて話すとき、このルールはどうでしょうか?
template <typename T> class B {
void DontKnowFunction() { T a = 0; }
// Will this function be treated as inline when the compiler
// instantiates the template?
};
また、inline
ルールはネストされていないテンプレート関数にどのように適用されますか?
template <typename T> void B::DontKnowFunction() { T a = 0; }
template <typename T> inline void B::DontKnowFunction() { T a = 0; }
ここで最初のケースと 2 番目のケースでは何が起こるでしょうか?
ありがとうございました。