Thread View: comp.std.c++
5 messages
5 total messages
Started by Brian Michael Freyburger
Mon, 15 Apr 1996 21:47
Template argument deduction
Author: Brian Michael Freyburger
Date: Mon, 15 Apr 1996 21:47
Date: Mon, 15 Apr 1996 21:47
28 lines
1354 bytes
1354 bytes
Reading section 14.10.2 of the January WP, I can not figure out
whether the following function call can be deduced:
template <class S, class T = S>
int foo(S s, T t = T());
int bar()
{
foo(1);
}
The compiler must deduce that S is int from the one argument
specified, then determine that T is int from the default parameter for
T, and finally determine that the second argument has the default
value of int().
Thanks,
Brian Freyburger
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Re: Template argument deduction
Author: David Vandevoorde
Date: Thu, 18 Apr 1996 00:49
Date: Thu, 18 Apr 1996 00:49
17 lines
1435 bytes
1435 bytes
>>>>> "BF" == Brian Michael Freyburger <freyburg@glitch.stanford.edu> writes: BF> Reading section 14.10.2 of the January WP, I can not figure out BF> whether the following function call can be deduced: BF> template <class S, class T = S> BF> int foo(S s, T t = T()); It's a non-issue since default template arguments cannot be specified for function templates. Daveed --- [ comp.std.c++ is moderated. To submit articles: try just posting with ] [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ] [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ] [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ] [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Re: Template argument deduction
Author: Brian Michael Freyburger
Date: Thu, 18 Apr 1996 21:14
Date: Thu, 18 Apr 1996 21:14
30 lines
1799 bytes
1799 bytes
> >>>>> "BF" == Brian Michael Freyburger <freyburg@glitch.stanford.edu> writes: > BF> Reading section 14.10.2 of the January WP, I can not figure out > BF> whether the following function call can be deduced: > > BF> template <class S, class T = S> > BF> int foo(S s, T t = T()); > > It's a non-issue since default template arguments cannot be > specified for function templates. > > Daveed Where in the working papers does it say this? They appear to me to be introduced in 14.8 [temp.arg], which as far as I can tell applies to both functions and classes. I see nothing in 14.10 [temp.fct] which disallows them--what did I miss? Why are they disallowed? Are there any technical difficults? Thanks, Brian [ comp.std.c++ is moderated. To submit articles: try just posting with ] [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ] [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ] [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ] [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Re: Template argument deduction
Author: David Vandevoorde
Date: Fri, 19 Apr 1996 14:43
Date: Fri, 19 Apr 1996 14:43
26 lines
1937 bytes
1937 bytes
>>>>> "BF" == Brian Michael Freyburger <freyburg@wavelet.stanford.edu> writes: I (Daveed) wrote: >> It's a non-issue since default template arguments cannot be >> specified for function templates. BF> Where in the working papers does it say this? They appear to me BF> to be introduced in 14.8 [temp.arg], which as far as I can tell BF> applies to both functions and classes. I see nothing in 14.10 BF> [temp.fct] which disallows them--what did I miss? Good point ;^P It's not in the April '95 CD, apparently :^( However, it's in the Templates chapter as revised for the Santa Cruz meeting. Sorry for the confusion, I didn't realize this was this recent. BF> Why are they disallowed? Are there any technical difficults? The problem you mentioned maybe ;-) Daveed [ comp.std.c++ is moderated. To submit articles: try just posting with ] [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ] [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ] [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ] [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Re: Template argument deduction
Author: Matt Austern
Date: Fri, 19 Apr 1996 14:49
Date: Fri, 19 Apr 1996 14:49
40 lines
2682 bytes
2682 bytes
In article <FREYBURG.96Apr18141053@wavelet.stanford.edu> freyburg@wavelet.stanford.edu (Brian Michael Freyburger) writes: > > It's a non-issue since default template arguments cannot be > > specified for function templates. > > > > Daveed > > Where in the working papers does it say this? They appear to me to be > introduced in 14.8 [temp.arg], which as far as I can tell applies to > both functions and classes. I see nothing in 14.10 [temp.fct] which > disallows them--what did I miss? That's right: there's nothing in the WP that disallows default template arguments for functions; there's also nothing there, though, that says what their semantics would be if they were allowed. The committee had to choose between defining the semantics of default template arguments for functions, or simply disallowing them; it chose the latter. This decision was made at the Santa Cruz meeting, so it isn't yet reflected in a new version of the WP. I don't think there would have been any technical problems with allowing default template arguments for function templates; it's just that it would have required a fair amount of work to come up with a clear set of rules. (I can think of at least three or four issues that would have had to be resolved, which probably means that there are another dozen that I haven't thought of.) The general feeling was that the feature wouldn't have been important enough to be worth that much effort. -- Matt Austern SGI: MTI Compilers Group austern@isolde.mti.sgi.com --- [ comp.std.c++ is moderated. To submit articles: try just posting with ] [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ] [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ] [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ] [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads