From -8986677194675480341
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,96269def683bbee1,start
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2004-02-07 13:56:32 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.icl.net!newsfeed.fjserv.net!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull
From: jarkko@videotron.ca ("Jarkko Lempiainen")
Newsgroups: comp.std.c++
Subject: proposal: template argument ellipsis
Date: Sat, 7 Feb 2004 21:56:30 +0000 (UTC)
Lines: 58
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <jS%Ub.95378$nL.1581395@weber.videotron.net>
X-Trace: mail2news.demon.co.uk 1076190990 17618 10.0.0.1 (7 Feb 2004 21:56:30 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Sat, 7 Feb 2004 21:56:30 +0000 (UTC)
X-Received: from mulga.cs.mu.oz.au ([128.250.1.22])
	by news.demon.co.uk with esmtp (Exim 4.12)
	id 1ApaRB-0004a0-00
	for mail2news@news.news.demon.net; Sat, 07 Feb 2004 21:56:29 +0000
X-Received: from mulga.cs.mu.OZ.AU (localhost [127.0.0.1]) by mulga.cs.mu.OZ.AU with ESMTP
	id i17LuOi2009691; Sun, 8 Feb 2004 08:56:24 +1100 (EST)
X-Received: (from fjh@localhost)
	by mulga.cs.mu.OZ.AU (8.12.10+Sun/8.12.9/Submit) id i17LuNm1009682;
	Sun, 8 Feb 2004 08:56:23 +1100 (EST)
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Path: comp-std-cpp-robomod!not-for-mail
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Delivered-To: std-c++@ucar.edu
X-Reply-To: "Jarkko Lempiainen" <jarkko@videotron.ca>
X-Newsgroups: comp.std.c++
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
X-NNTP-Posting-Date: Sat, 07 Feb 2004 01:47:43 EST
X-Spam-Level: 
X-Spam-Checker-Version: SpamAssassin 2.60-mulga_r1 (1.212-2003-09-23-exp) on 
	mulga.cs.mu.OZ.AU
X-Spam-Status: No, hits=0.7 required=5.2 tests=PRIORITY_NO_NAME autolearn=no 
	version=2.60-mulga_r1
Xref: archiver1.google.com comp.std.c++:1059

Hi,

I have sometimes faced the need to have variable
number of variable type arguments and to be able
to pass the list of arguments to another function
(in some very generic piece of code). For now I
have had to get around the lack of "template
argument ellipsis" with an ugly macro construct
(has its own set of problems) which overloads
the function, but it would be nice to have this
feature built-in to the language. The syntax
of the function declaration might look something
like this ("..." syntax might clash with the
existing ellipsis syntax, but I use it just to
make the point):

template<typename T_, ...>
T_ *myNew(...)
{
  return new(...);
}

And it could be called like this:

struct A
{
  A(float a_, const char *b_)  {/*...*/}
};

myNew<A>(1.0f, "foo");

The "template argument ellipsis" might be useful
for class templates as well:

template<typename T_, ...>
struct Tuple
{
  T_ head;
  Tuple<...> tail;
};

template<typename T_>
struct Tuple
{
  T_ head;
};

Has there been proposal for such a language
feature already?

Thanks, Jarkko

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



