public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Template parameters problem
@ 2006-06-27 17:35 Pierre Chatelier
  2006-06-27 18:01 ` Oliver Kullmann
  0 siblings, 1 reply; 3+ messages in thread
From: Pierre Chatelier @ 2006-06-27 17:35 UTC (permalink / raw)
  To: gcc-help

Hello,

gcc reports an error that I do not understand; does anyone know if it  
is a bug or some corner case of the standard ?

#include <map>
#include <string>
using namespace std;

void resetBar(const map<int,char>& foo = map<int,char>())
{
}//ok

struct Foo
{
   void resetFoo(const map<int,char>& foo = map<int,char>())
   {
   }//error (main.cpp:11: error: expected ',' or '...' before '>' token
                 main.cpp:11: error: wrong number of template  
arguments (1, should be 4))
};

Regards,

Pierre Chatelier

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

* Re: Template parameters problem
  2006-06-27 17:35 Template parameters problem Pierre Chatelier
@ 2006-06-27 18:01 ` Oliver Kullmann
  2006-06-27 18:25   ` Pierre Chatelier
  0 siblings, 1 reply; 3+ messages in thread
From: Oliver Kullmann @ 2006-06-27 18:01 UTC (permalink / raw)
  To: Pierre Chatelier, gcc-help

On Tue, Jun 27, 2006 at 07:35:38PM +0200, Pierre Chatelier wrote:
> Hello,
> 
> gcc reports an error that I do not understand; does anyone know if it  
> is a bug or some corner case of the standard ?
> 
> #include <map>
> #include <string>
> using namespace std;
> 
> void resetBar(const map<int,char>& foo = map<int,char>())
> {
> }//ok
> 
> struct Foo
> {
>   void resetFoo(const map<int,char>& foo = map<int,char>())
>   {
>   }//error (main.cpp:11: error: expected ',' or '...' before '>' token
>                 main.cpp:11: error: wrong number of template  
> arguments (1, should be 4))
> };
> 
> Regards,
> 
> Pierre Chatelier

Hi,

it must be

struct Foo
{
  void resetFoo(const std::map<int,char>& foo = (std::map<int,char>()))
  {
  }
};

to disambiguate the syntax (declaration vs. definition; I believe that this is not a compiler issue;
in such cases often additional brackets help, since they are allowed around
expressions, but not around argument lists).

Oliver

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

* Re: Template parameters problem
  2006-06-27 18:01 ` Oliver Kullmann
@ 2006-06-27 18:25   ` Pierre Chatelier
  0 siblings, 0 replies; 3+ messages in thread
From: Pierre Chatelier @ 2006-06-27 18:25 UTC (permalink / raw)
  To: gcc-help

> it must be
>
> struct Foo
> {
>   void resetFoo(const std::map<int,char>& foo = (std::map<int,char> 
> ()))
>   {
>   }
> };
>
> to disambiguate the syntax

Hello,

Thanks, you are right, it works.
In the meantime, I finally found out that it was a kind of old known  
"bug" (bug #57 in gcc bugzilla).
Regards,

Pierre Chatelier

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

end of thread, other threads:[~2006-06-27 18:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-27 17:35 Template parameters problem Pierre Chatelier
2006-06-27 18:01 ` Oliver Kullmann
2006-06-27 18:25   ` Pierre Chatelier

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).