P
pauljwilliams
Consider the following scenario:
A template class Diag is defined for a generic class T, with a single
member function, State(), returning a boolean, defined as returning
false.
For some types T, the template is specialized such that State returns
true. In this sense, the template class as akin to a policy class.
At compile time, how does the compiler search the source tree for all
possible specialisations?
If i have a line:
if ( Diag<MyType>().State() )
{
....do something...
}
How will the compiler know that there is (or isnt) a specialisation of
Diag for MyType? How far will it look?
Thanks in advance
A template class Diag is defined for a generic class T, with a single
member function, State(), returning a boolean, defined as returning
false.
For some types T, the template is specialized such that State returns
true. In this sense, the template class as akin to a policy class.
At compile time, how does the compiler search the source tree for all
possible specialisations?
If i have a line:
if ( Diag<MyType>().State() )
{
....do something...
}
How will the compiler know that there is (or isnt) a specialisation of
Diag for MyType? How far will it look?
Thanks in advance