D
Dave Rahardja
Hi all,
Is it possible to prevent _at compile or link time_ the mulitple instantiation
of a templated function? In other words, if there exists a function
template <typename T> void fn();
I want to prevent the user from doing this:
int main()
{
fn<int>();
fn<double>(); // <-- should cause compile time or link time error
}
It matters that there is only one instance of the function in the entire
program. It doesn't matter which type becomes instantiated, but there cannot
be two references to the function with two different type parameters.
If this is possible, then is there a way to do this for _any_ templated
entity?
-dr
Is it possible to prevent _at compile or link time_ the mulitple instantiation
of a templated function? In other words, if there exists a function
template <typename T> void fn();
I want to prevent the user from doing this:
int main()
{
fn<int>();
fn<double>(); // <-- should cause compile time or link time error
}
It matters that there is only one instance of the function in the entire
program. It doesn't matter which type becomes instantiated, but there cannot
be two references to the function with two different type parameters.
If this is possible, then is there a way to do this for _any_ templated
entity?
-dr