When the user drags an inheritance line to a template or specialization, what would be good defaults for the generated template arguments?
Say in code I have...
template <class T> List {};
class MyClientList {};
The user drags an inheritance line from MyClientList to List<T>. Currently we have set the default template argument to “int” and so the code generated will be…
template <class T> List {};
// We generate the inheritance to code
// and instantiated template List<int>
class MyClientList : public List<int> {};
And here is one of the issues we run into.
If the code was this…
template <class T> List {};
template <> List <int> {};
class MyClientList : public List<int> {};
Our default as “int” is wrong, because the user intended to inherit from the primary template List<T> and not from List<int>. You can think of various other cases where keeping the default as "int" would generate wrong and even code that wouldn't compile.
I would like to get your feedback on what would be a good default template argument.
I was thinking that we will not try to generate any default. We will just plop the parameter names as they appear.
So for the above example when the user dragged an inheritance from MyClientList to List<T> we would generate…
template <class T> List {};
template <> List <int> {};
// Note that the default template
// argument in now “T” instead of “int”
class MyClientList : public List<T> {};
Yes it doesn’t compile, but is it better than default always being “int”? And also note that you can select the inheritance line and change the template arguments.
Please post your feedback and I am sure you will have some better suggestions.