🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac.programmer.codewarrior
Article #590

template default argument bug?

#590
From: Edward Chew
Date: Thu, 05 Feb 2004 18:21
27 lines
1959 bytes
Here is an example straight out of Stroustrup:

//----------

template<class T> class String;

template<class T> class Cmp {
public:
	static int eq(T a, T b) { return a == b; }
	static int lt(T a, T b) { return a < b; }
};

template<class T, class C = Cmp<T> >
int compare(const String<T>& str1, const String<T>& str2);

//----------

I compile this in CodeWarrior for Mac OS 8.3 and get:

Error: illegal use of default template-argument

If I comment out the /* = Cmp<T> */ it compiles fine.  If I turn the 
compare function into a class with the same default argument, it is also 
happy.  Sounds like a compiler bug to me, unless I am missing something 
obvious.

-Ted
Technical Details
Message-ID: <4022896d$1@news.kos.net>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!zeus.visi.com!news-out.visi.com!green.octanews.net!news-out.octanews.net!news.moat.net!newsfeed.slurp.net!news.kos.net!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10bcce,7802dbc009c85cd,start
X-Google-Attributes: gid10bcce,public
X-Google-Thread: f635e,7802dbc009c85cd,start
X-Google-Attributes: gidf635e,public
X-Google-ArrivalTime: 2004-02-05 10:22:18 PST
Date: Thu, 05 Feb 2004 13:21:49 -0500
From: Edward Chew <ekc-noreply@lgl.kos.net>
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.6a) Gecko/20031029
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: comp.sys.mac.programmer.codewarrior,codewarrior.mac
Subject: template default argument bug?
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
X-Original-NNTP-Posting-Host: 216.185.95.133
Message-ID: <4022896d$1@news.kos.net>
X-Original-Trace: 5 Feb 2004 13:20:29 -0500, 216.185.95.133
Organization: Kingston Online Services
Lines: 27
NNTP-Posting-Host: apollo.kos.net
X-Trace: newsfeed.slurp.net 1075917502 199.246.2.51 (4 Feb 2004 12:58:22 -0500)
X-Original-NNTP-Posting-Host: 199.246.2.51
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!zeus.visi.com!news-out.visi.com!green.octanews.net!news-out.octanews.net!news.moat.net!newsfeed.slurp.net!news.kos.net!not-for-mail