Community
Participate
Working Groups
Say you have class A1 { void action1(); void action2(); ... }; class A2 { void action1(); void action2(); }; i.e. two or more classes that have a similar interface. and then a template class that will use either A1 or A2 as template parameter: template <class A> class DoSomethingWithA { void do(A a) { //now a. will not bring up code assist because obviously A is an unknown class } }; I propose that when I write template <class A /*as A1*/> class DoSomethingWithA { void do(A a) { //now code assist "knows" that A has an interface similar to A1 // and can offer completions for a. // all that has to be done is to parse the class name after "/*as " // and copy the completions from A1 to A } }
This is an interesting idea. Technically, during the lookup for content assist, we'd need to map the template parameters to the specified class. However, currently I don't have time to spend on this.
I think the proper solution to problems like this is Concepts. In the C++0x concepts design, you could do something like this: concept A { void action1(); void action2(); }; class A1 // implicitly models A { void action1(); void action2(); }; class A2 // implicitly models A { void action1(); void action2(); }; template <A T> // parameter T must model concept A class DoSomethingWithA { void do(T a) { a. // CDT can look in A to see what methods to offer } }; Unfortunately, this Concepts design did not make it into C++11 and was abandoned. A new Concepts design is currently in the works [1], with part of it ("Concepts Lite") headed for C++14, and a more complete design hopefully headed for C++17. It is not yet clear to me what the complete design will look like, but hopefully it will also provide a nice solution to problems like this. [1] http://concepts.axiomatics.org/
Since Concepts will provide a solution for this, I'm going to close this as WONTFIX. If someone feels that the original request is worth implementing, feel free to reopen.