[cfe-dev] clang c++0x template function declaration error
Seth Cantrell
seth.cantrell at gmail.com
Sat Jul 16 09:31:36 PDT 2011
Could the diagnostics be improved over
> test.cpp:4:6: note: candidate template ignored: substitution failure
> [with T = Y]
> auto type_constructor( void (T::*f)() ) -> X< T, f >;
> ^
?
Maybe an added note that points at the f in X<T,f> to say that that's why the substitution failed?
Here's an example of a similar mistake:
> #include <functional>
>
> template<typename T>
> void get(T const &t,size_t N) {
> std::get<N>(t);
> }
>
> int main () {
> get(std::make_tuple(1,'a',1.2),2);
> }
When compiling this the diagnostics include several notes like the following
> /usr/include/c++/v1/__tuple:104:1: note: candidate template ignored: invalid explicitly-specified
> argument for template parameter '_Ip'
> get(array<_Tp, _Size>&) _NOEXCEPT;
"invalid explicitly-specified argument for template parameter" is a little better but it'd be nice to see something pointing directly at the 'N' in std::get<N>(t) saying it's not legal to use arguments as template parameters. Would this be hard to add? Maybe I can give it a try.
On Jul 4, 2011, at 2:31 PM, John Freeman wrote:
> On 7/4/2011 1:03 PM, Eli Friedman wrote:
>> The declaration of the template type_constructor is broken. Think
>> about it this way: type_constructor has one template parameter, so
>> type_constructor<Y> should refer to a single function; however, you're
>> trying to specify it as returning multiple types.
>
> Or put another way, the second template argument for X, "foo", should be
> a constant function pointer, but the parameter to type_constructor, "f",
> is not.
>
> - John
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list