Postincrement causes match problem - bug or feature?

John Fine johnsfine@verizon.net
Mon Sep 29 16:54:00 GMT 2008


The postincrement makes a difference because the result of the 
postincrement is a temporary value.

You can't pass a temporary value by non const reference.

IIUC, your results would be different if the first definition had const 
in it as follows:

template <typename T>
int foo(T const& t1)
{
  cerr << "Got in #1!\n";
  return 0;
}



Andrew Bell wrote:
> On Mon, Sep 29, 2008 at 10:51 AM, John Love-Jensen <eljay@adobe.com> wrote:
>   
>> Hi Andrew,
>>
>> The compiler cannot decide which of the two foo functions are more suitable,
>> since they are both equally suitable.
>>     
>
> The real question is why the postincrement makes a difference.  Can you explain?
>
>   



More information about the Gcc-help mailing list