From 557418375120098538
X-Google-Thread: 7894ca11fe,40de2bc986604261
X-Google-Attributes: gid7894ca11fe,public,usenet
X-Google-NewGroupId: yes
X-Google-Language: ENGLISH,ASCII
Path: g2news2.google.com!news2.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Sun, 04 Oct 2009 02:40:29 -0500
Return-Path: <cppmods@ruralroute.cs.rpi.edu>
To: (Usenet)
From: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@googlemail.com>
Newsgroups: comp.std.c++
Subject: Re: Templates as default arguments
Organization: http://groups.google.com
Sender: cppmods@cs.rpi.edu
Approved: james.dennett@gmail.com
Message-ID: <9ab9b3d4-311c-40a9-ab3f-2f5b69eb782a@l35g2000vba.googlegroups.com>
References: <a9f9b3ad-96c5-4ad9-aca0-c50ec493b09e@z24g2000yqb.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
X-Original-Date: Sat, 3 Oct 2009 07:57:44 -0700 (PDT)
X-Submission-Address: std-c++@netlab.cs.rpi.edu
Date: Sun,  4 Oct 2009 02:37:32 CST
Lines: 59
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-nOmaROhoDd6v0chmn7r1gV/K3Zxwn4K6hil/gb10rsDswMeV8mMsmuvA0Doa8HwjvdHgwM5Mdgjqn5n!KE3gnxPbrbW5bFJlUDzGcHqSRpVo2PSDNiwtTiwdQAA6e7ta0yTaDmO4Ygl364+iJK0je78gmF9G!5F9OGuX28Jioiui3cCEsMRvQy7g=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
Xref: g2news2.google.com comp.std.c++:1428

On 2 Okt., 23:21, dps <serviss...@gmail.com> wrote:
> Hi,
>
> I have the following situation:
>
> template<typename T, int i> class A
> {
>      A(){}
>
> };
>
> class B
> {
> public:
>      B(A<double,3> arg=A<double,3>()){}
>
> }
>
> The above is pseudo-code and compiles on VS but not on gcc. Gcc
> complains about the "3" in the default argument. But if I write
>
> class B
> {
> public:
>      typedef A<double,3> AD3;
>      B(AD3 arg=AD3()){}
>
> there is no problem. Obviously it has to do with the template
> instantiation? But why is only the "3" that creates the problem?

I don't believe that the "3" is the problem. The example
you provided is ill-formed (e.g. private default constructor) and
I don't recommend to provide a "pseudo-code" for a situation
that causes a problem, because this has the fundamental
tendency to hide the actual problem. Pseudo-code makes
sense if you want to present a new idea, because it emphasizes
your *idea* what the code should do, but is a bad choice for
to present a situation which causes a compile or runtime problem,
because to solve this one isn't primarily interested to get your
idea, but to understand the nature of the problem.

It would also be helpful, if you have provided us information
about the compiler versions. From what you present here
it looks like a compiler error. If the default constructor was
actually public and the class definition of B is completed with
a semicolon and the code still causes a compiler error, this is
a clearly a compiler defect.

HTH && Greetings from Bremen,

Daniel Kr�gler


--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]



