dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #24320
Re: Template help
On 31 August 2011 16:12, Anders Logg <logg@xxxxxxxxx> wrote:
> I want to declare the following function:
>
> template<class S, class T>
> void apply_markers(S<T>& sub_domains, T sub_domain) const;
>
> S is a template class (either MeshFunction or MeshMarkers) and T is a
> primitive type.
>
> The above declaration does not work. How should it be declared? I've
> tried various other combinations without success.
If you can make T a typedef in S, this works:
template<typename V>
class Foo
{
public:
typedef V value_type;
};
template<typename S>
void apply_markers(S & sub_domains, typename S::value_type sub_domain)
{
S s;
}
int main(int argc, char *argv[])
{
Foo<int> a;
apply_markers< Foo<int> >(a, 3);
return 0;
}
Follow ups
References