L
Lewis Baker
I am having some template problems in VC7.1
The following code should compile fine but I get the error:
'warning C4667: 'void F(Traits<T>:
)' : no function
template defined that matches forced instantiation'
However if I instantiate the function implicitly by using
it in some code then everything seems to work.
Any clues or is this a compiler bug?
Regards,
Lewis
---- Code below ----
// Traits class
template<class T>
class Traits
{
public:
typedef T* P;
};
// Template function declaration
template<class T> void F( typename Traits<T>:
);
// Template function definition
template<class T>
void F( typename Traits<T>:
X )
{
Traits<T>:
x = X;
}
// Explicitly instantiate function
template void F( Traits<int>:
); // <-- Error here
// Implicitly instantiate function
void UseF()
{
int a;
F<int>( &a ); // <-- No problems
}
The following code should compile fine but I get the error:
'warning C4667: 'void F(Traits<T>:

template defined that matches forced instantiation'
However if I instantiate the function implicitly by using
it in some code then everything seems to work.
Any clues or is this a compiler bug?
Regards,
Lewis
---- Code below ----
// Traits class
template<class T>
class Traits
{
public:
typedef T* P;
};
// Template function declaration
template<class T> void F( typename Traits<T>:

// Template function definition
template<class T>
void F( typename Traits<T>:

{
Traits<T>:

}
// Explicitly instantiate function
template void F( Traits<int>:

// Implicitly instantiate function
void UseF()
{
int a;
F<int>( &a ); // <-- No problems
}