public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* template specialization, is this valid C++?
@ 2013-11-12 17:23 andre maute
  2013-11-12 18:27 ` Jonathan Wakely
  0 siblings, 1 reply; 2+ messages in thread
From: andre maute @ 2013-11-12 17:23 UTC (permalink / raw)
  To: gcc-help

gcc version 4.7.2 20121109 (Red Hat 4.7.2-8) (GCC)
compiles the following code under Fedora.

My question is,
if the omitting of the second template parameter of f,
is valid C++?

Andre

------------------------------------
#include <iostream>

template< int size, class T >
int f( int x, T& t )
{
         return size + x;
}

int main()
{
         double z = 1.0;
         std::cout << f<11>(22,z) << std::endl;
         return 0;
}
-------------------------------------

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: template specialization, is this valid C++?
  2013-11-12 17:23 template specialization, is this valid C++? andre maute
@ 2013-11-12 18:27 ` Jonathan Wakely
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2013-11-12 18:27 UTC (permalink / raw)
  To: andre maute; +Cc: gcc-help

On 12 November 2013 17:23, andre maute wrote:
> gcc version 4.7.2 20121109 (Red Hat 4.7.2-8) (GCC)
> compiles the following code under Fedora.
>
> My question is,
> if the omitting of the second template parameter of f,
> is valid C++?

This is a general C++ question, not specific to GCC, so there are
better places to ask than here.

However the answer is yes, the second template argument is deduced
from the function argument, which has type double.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-11-12 18:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-12 17:23 template specialization, is this valid C++? andre maute
2013-11-12 18:27 ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).