MESSAGE
DATE | 2011-05-24 |
FROM | Ruben Safir
|
SUBJECT | Re: [NYLXS - HANGOUT] [ruben@mrbrklyn.com: Re:
|
From owner-hangout-outgoing-at-mrbrklyn.com Tue May 24 13:31:12 2011 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: by www2.mrbrklyn.com (Postfix) id 23F80100B1E; Tue, 24 May 2011 13:31:12 -0400 (EDT) Delivered-To: hangout-outgoing-at-www2.mrbrklyn.com Received: by www2.mrbrklyn.com (Postfix, from userid 28) id 0EDD9100B22; Tue, 24 May 2011 13:31:11 -0400 (EDT) Delivered-To: hangout-at-nylxs.com Received: from mailbackend.panix.com (mailbackend.panix.com [166.84.1.89]) by www2.mrbrklyn.com (Postfix) with ESMTP id AB1D2100B1E for ; Tue, 24 May 2011 13:31:11 -0400 (EDT) Received: from panix5.panix.com (panix5.panix.com [166.84.1.5]) by mailbackend.panix.com (Postfix) with ESMTP id 359CE32315 for ; Tue, 24 May 2011 13:31:33 -0400 (EDT) Received: by panix5.panix.com (Postfix, from userid 20529) id 33CE72424F; Tue, 24 May 2011 13:31:33 -0400 (EDT) Date: Tue, 24 May 2011 13:31:33 -0400 From: Ruben Safir To: hangout-at-nylxs.com Subject: Re: [NYLXS - HANGOUT] [ruben-at-mrbrklyn.com: Re: [mrbrklyn-at-panix.com: Template Argument type deterination]] Message-ID: <20110524173132.GB20420-at-panix.com> References: <20110524172525.GC21131-at-panix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110524172525.GC21131-at-panix.com> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: owner-hangout-at-mrbrklyn.com Precedence: bulk Reply-To: hangout-at-mrbrklyn.com
Path: reader1.panix.com!panix!newsfeed-00.mathworks.com!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!news2.euro.net!feeder.news-service.com!85.214.198.2.MISMATCH!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Victor Bazarov Newsgroups: comp.lang.c++ Subject: Re: Template argument determination Date: Tue, 24 May 2011 11:43:26 -0400 Organization: A noiseless patient Spider Lines: 49 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 24 May 2011 15:43:27 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="mfoyPVXLF0MtM1ZkAsRgyQ"; logging-data="31217"; mail-complaints-to="abuse-at-eternal-september.org"; posting-account="U2FsdGVkX1/C7I8P09Pb9rAZBZkqJC1eaXCrnxP8Yw0=" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 In-Reply-To: Cancel-Lock: sha1:xwmh1LRs4qzK91MZjldtaTdR8fE= Xref: panix comp.lang.c++:1085263
On 5/24/2011 11:04 AM, Ruben Safir wrote: > Lets look at it this way > > why does this fail to compile > > template > void test_me(stats::Distribution hello){ > std::cout<< "I recied an int and converted it to an object "<< > hello<< std::endl; > } > > > > int main ( int argc, char *argv[] ){ > int a = 7; > test_me(a); > > return EXIT_SUCCESS; > }
You ask the compiler to find what 'T' would be. During template argument deduction the compiler does NOT use any potential promotions or conversions. The fact that 'stats::Distribution' has a conversion from 'int' has *no importance* to the template argument deduction process.
> > > yet this does, with the promotion of the int to a distribution object > > > template > void test_me(stats::Distribution hello){ > std::cout<< "I received an int and converted it to an object "<< > hello<< std::endl; > } > > > int main ( int argc, char *argv[] ){ > int a = 7; > test_me(a);
Here no template argument deduction is necessary since you supplied the argument.
> > return EXIT_SUCCESS; > }
V -- I do not respond to top-posted replies, please don't ask
|
|