-
-
Notifications
You must be signed in to change notification settings - Fork 262
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Example:
namespace ns
{
template <typename T>
struct foo
{
T value;
};
template class foo<int>; // [1]
}
template struct ns::foo<double>; // [2]
int main()
{
}Result is:
namespace ns
{
template<typename T>
struct foo
{
T value;
};
template<>
struct foo<int>
{
int value;
};
template<>
struct foo<double>
{
double value;
};
template<>
struct foo<int>
{
int value;
};
}
template<>
struct ns::foo<double>
{
double value;
};
// [2]
int main()
{
}
Live demo: https://t.co/puhOYbbT3c?amp=1
The same does not happen for function templates.
Example:
namespace ns
{
template <typename T>
void foo(T const value)
{
}
template void foo(int); // [1]
}
template void ns::foo(double); // [2]
int main()
{
}Result:
namespace ns
{
template<typename T>
void foo(const T value)
{
}
/* First instantiated from: insights.cpp:8 */
#ifdef INSIGHTS_USE_TEMPLATE
template<>
void foo<int>(const int value)
{
}
#endif
/* First instantiated from: insights.cpp:11 */
#ifdef INSIGHTS_USE_TEMPLATE
template<>
void foo<double>(const double value)
{
}
#endif
}
template void ns::foo(double); // [2]
int main()
{
}Live demo: https://t.co/OkuTBT3Lwd?amp=1
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working