Community
Participate
Working Groups
Created attachment 230631 [details] example of the issue I am using nested template with member pointers List<N>::Base<&N::node_member>, this compiles ok, but codecan report 'invalid template arguments'.
Reduced example: struct N { int node; }; template <typename T> struct List { template <int T::*> struct Base {}; }; List<N>::Base<&N::node> base; // ERROR: Invalid template argument
*** Bug 407496 has been marked as a duplicate of this bug. ***
The problem is that when specializing List<T>::Base to be List<N>::Base, the substitution T = N is not performed on the T in Base's template parameter.
(In reply to comment #3) > The problem is that when specializing List<T>::Base to be List<N>::Base, the > substitution T = N is not performed on the T in Base's template parameter. Unfortunately, fixing this is not as easy as I hoped. Unlike a template argument, which is just a thin wrapper for a type or an evaluation, a template parameter is a binding, and conceptually, subtituting template arguments within one yields a new, specialized binding. I think we will have to introduce new binding types for template parameter specializations.
See also bug 399454, where a similar problem occurs, but with the nested template's template parameter's default value rather its type.
Patch (also fixes bug 399454): https://git.eclipse.org/r/#/c/14533/
Updated patch to fix a bug in EvalTypeId.unmarshal() that caused an NPE (the bug had always been there, but the changes in this patch exposed it).
*** cdt git genie on behalf of Nathan Ridge *** Bug 407497, Bug 399454 - Specialize template parameters when appropriate Change-Id: Iff52b04319234ca8e5fe0f9b23d5d1787cee4449 Signed-off-by: Nathan Ridge <zeratul976@xxxxxxxxxxx> Reviewed-on: <a href="https://git.eclipse.org/r/14533">https://git.eclipse.org/r/14533</a> Reviewed-by: Sergey Prigogin <eclipse.sprigogin@xxxxxxxxx> IP-Clean: Sergey Prigogin <eclipse.sprigogin@xxxxxxxxx> Tested-by: Sergey Prigogin <eclipse.sprigogin@xxxxxxxxx> [*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=2050fe2bfb91b213a99f00033f19a11a90b903c9
Fixed in 8.2.1 and master.
(In reply to Nathan Ridge from comment #1) > Reduced example: > > > struct N > { > int node; > }; > > template <typename T> > struct List > { > template <int T::*> > struct Base {}; > }; > > List<N>::Base<&N::node> base; // ERROR: Invalid template argument This is giving me a "Unsafe method call. Instantiation of dependent expressions may not work", see bug 416284. Using 8.2.1 RC1 (EPP 20130821-2252).