Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #5639
| Newsgroups | comp.lang.c++ |
|---|---|
| From | "A. Bolmarcich" <aggedor@earl-grey.cloud9.net> |
| Subject | Re: Template argument determination |
| References | <irh227$8du$1@dont-email.me> <slrnitob96.77f.aggedor@earl-grey.cloud9.net> <irhdh7$na0$1@dont-email.me> <slrnitqfiq.10rf.aggedor@earl-grey.cloud9.net> <irlu67$6kt$2@reader1.panix.com> |
| Message-ID | <slrnitt6od.23jf.aggedor@earl-grey.cloud9.net> (permalink) |
| Date | 2011-05-26 13:25 -0500 |
On 2011-05-26, Ruben Safir <ruben@mrbrklyn.com> wrote:
> On Wed, 25 May 2011 12:37:30 -0500, A. Bolmarcich wrote:
[snip]
>> I snipped from your post all but what you wrote and explained the
>> difference between using
>>
>> foo(42)
>>
>> and
>>
>> foo<int>(42)
>>
>> in the example you wrote. With foo(42), the function template argument
>> was neither explicitly specified nor deduced, and the template was not
>> instantiated.
>>
>
>
> I don't understand this.
I'll break it into smaller pieces. The expression
foo(42)
does not explicity specify a template argument; the expression
foo<int>(42)
explicitly specifies a template argument.
With the expression foo(42) the compiler is not able to deduce the
template argument (T) for
template <class T>
void foo(X<T>) {}
because the rules for template argument deduction do not include one
that matches the int function argument (42) with the function
parameter type X<T>.
[snip]
>> What Ruben wrote was: "But its not capable of doing this implicit
>> conversion unless T is defined as an int." Your reading missed some of
>> the words Ruben wrote. I wrote that an implicit conversion from
>> function arguments to function parameters should be done even if T is
>> defined as something other than an int.
>
> See the language started to get very confusing. We have template
> parameters, function parameters, template arguments, function
> arguments...my head is swiming and to make it harder, you keep
> substituting structs for classes.
In the function declaration
void f1(int fp)
fp is a function parameter. In the function call
f1(42)
42 is a function argument. In the template
template <class T>
void f2(T x) {}
T is a template parameter. In the function call
f2<int>(42)
int is a template argument. It is an explicitly specified template
argument.
In C++ a struct is a class whose members are public by default.
Using a struct instead of a class in short examples eliminates the
need to add
public:
in a class to make the example compile.
[snip]
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar
Template argument determination Ruben Safir <ruben@mrbrklyn.com> - 2011-05-23 20:31 +0000
Re: Template argument determination Ruben Safir <ruben@mrbrklyn.com> - 2011-05-24 02:50 +0000
Re: Template argument determination Michael Doubez <michael.doubez@free.fr> - 2011-05-24 03:48 -0700
Re: Template argument determination "Balog Pal" <pasa@lib.hu> - 2011-05-24 13:06 +0200
Re: Template argument determination Ruben Safir <ruben@mrbrklyn.com> - 2011-05-24 14:44 +0000
Re: Template argument determination Ruben Safir <ruben@mrbrklyn.com> - 2011-05-24 15:04 +0000
Re: Template argument determination "Balog Pal" <pasa@lib.hu> - 2011-05-24 17:33 +0200
Re: Template argument determination Victor Bazarov <v.bazarov@comcast.invalid> - 2011-05-24 11:43 -0400
Re: Template argument determination "A. Bolmarcich" <aggedor@earl-grey.cloud9.net> - 2011-05-24 12:32 -0500
Re: Template argument determination Ruben Safir <ruben@mrbrklyn.com> - 2011-05-24 18:08 +0000
Re: Template argument determination "A. Bolmarcich" <aggedor@earl-grey.cloud9.net> - 2011-05-24 14:32 -0500
Re: Template argument determination Victor Bazarov <v.bazarov@comcast.invalid> - 2011-05-24 15:48 -0400
Re: Template argument determination "A. Bolmarcich" <aggedor@earl-grey.cloud9.net> - 2011-05-24 17:11 -0500
Re: Template argument determination Victor Bazarov <v.bazarov@comcast.invalid> - 2011-05-24 19:04 -0400
Re: Template argument determination "A. Bolmarcich" <aggedor@earl-grey.cloud9.net> - 2011-05-25 12:37 -0500
Re: Template argument determination Ruben Safir <ruben@mrbrklyn.com> - 2011-05-26 16:12 +0000
Re: Template argument determination "A. Bolmarcich" <aggedor@earl-grey.cloud9.net> - 2011-05-26 13:25 -0500
Re: Template argument determination Ruben Safir <ruben@mrbrklyn.com> - 2011-05-25 02:47 +0000
Re: Template argument determination "Balog Pal" <pasa@lib.hu> - 2011-05-25 10:06 +0200
Re: Template argument determination "A. Bolmarcich" <aggedor@earl-grey.cloud9.net> - 2011-05-25 12:40 -0500
csiph-web