This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Template parameters problem
- From: Oliver Kullmann <O dot Kullmann at swansea dot ac dot uk>
- To: Pierre Chatelier <pierre dot chatelier at club-internet dot fr>, gcc-help at gcc dot gnu dot org
- Date: Tue, 27 Jun 2006 19:05:03 +0100
- Subject: Re: Template parameters problem
- References: <9DC23426-6E00-4CD1-968F-0D6A0AF147B7@club-internet.fr>
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