-
-
Notifications
You must be signed in to change notification settings - Fork 264
unexpected behavior when explicitly instantiating a template #123
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
I'm not sure what the expected behavior is, but this snippet shows no template instantiation code being generated:
template<typename T>
struct Person
{
int age, heightInInches;
T distanceTraveled = T(); //default value
float hairLength, GPA;
unsigned int SATScore;
T run(T speed, bool startWithLeftFoot);
};
template<typename T>
T Person<T>::run(T speed, bool left )
{
return speed + (left ? 1 : 0);
}
template struct Person<int>;
int main()
{
Person<int> f;
auto x = f.run(2, true);
}
If you comment out the template struct Person<int>; it generates the expected template code.
Any ideas on why this happens?
I was expecting to this:
/* First instantiated from: insights.cpp:22 */
#ifdef INSIGHTS_USE_TEMPLATE
template<>
struct Person<int>
{
int age;
int heightInInches;
int distanceTraveled = int();
float hairLength;
float GPA;
unsigned int SATScore;
int run(int speed, bool left)
{
return speed + (left ? 1 : 0);
}
// inline Person() noexcept = default;
// inline constexpr Person(const Person<int> &) = default;
// inline constexpr Person(Person<int> &&) = default;
};
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working