Template parameters problem

Oliver Kullmann O.Kullmann@swansea.ac.uk
Tue Jun 27 18:01:00 GMT 2006


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



More information about the Gcc-help mailing list