Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Explicit template instantiation through a typedef

Tags:

c++

templates

If I have

typedef Foo<float> Foof;

why can't I explicitly instantiate the template like this

template class Foof;

and is there a workaround apart from typing Foo<float>?

like image 570
Samaursa Avatar asked Jul 28 '12 23:07

Samaursa


1 Answers

and is there a workaround apart from typing Foo?

No, unfortunately there isn't. You have to type Foo<float>. As to why, see 14.7.2 clause 3 of the C++ standard for the rule (I don't know the rationale behind the rule though).

like image 174
Jesse Good Avatar answered Nov 18 '22 21:11

Jesse Good