Instantiating template functions in a conditional expression
Hello,
I want to select an instantiation of a template function
using a conditional expression, then call it.
The following works on other compilers, but
fails to link with CC:
sun02% cat simp1.cpp
template<class T> void foo(){};
int main()
{
bool thing=true;
(thing ? foo<int> : foo<float>)();
}
sun02% CC simp1.cpp
Undefinedfirst referenced
symbolin file
void foo<__type_0>()simp1.o
ld: fatal: Symbol referencing errors. No output written to a.out
If I take the templates out of the conditional all is well:
sun02% cat simp2.cpp
template<class T> void foo(){};
void(*f1)() = foo<int>;
void(*f2)() = foo<float>;
int main()
{
bool thing=true;
(thing ? f1 : f2)();
}
sun02% CC simp2.cpp
sun02%
Version is
sun02% CC -V
CC: Sun C++ 5.8 Patch 121017-02 2006/04/19
Can I report this one as a bug?
Thanks
-- Steve

