I only understan some simple template usage in C++.
Recently I met the following code snippet from some OpenFOAM code, and it confues me for weeks long.
(1) Could you please help me by giving a minimum working example to explain such "two consecutive templates" usage?
(2) Can I just replace the two tempalte with single template, i.e., template<Type, Type2>
Oh, please ignore the unknown classes such as Foam, fvMatrix.
Thanks~
template<class Type>
template<class Type2>
void Foam::fvMatrix<Type>::addToInternalField
(
const labelUList& addr,
const Field<Type2>& pf,
Field<Type2>& intf
) const
{
if (addr.size() != pf.size())
{
FatalErrorInFunction
<< "addressing (" << addr.size()
<< ") and field (" << pf.size() << ") are different sizes" << endl
<< abort(FatalError);
}
forAll(addr, facei)
{
intf[addr[facei]] += pf[facei];//intf是diag
}
}