Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Re: String lite...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 23 Topic 9495 of 9775
Post > Topic >>

Re: String literal as template parameter?

by Sean Hunt <rideau3@[EMAIL PROTECTED] > Apr 14, 2008 at 10:43 AM

On Apr 13, 6:23 pm, Daniel Krügler <daniel.krueg...@[EMAIL PROTECTED]
>
wrote:
> IMO the OP is aware that *current* C++ does not have
> variadic templates. But realizing that C++0x will
> be finished somewhere in 2009 his example is quite
> reasonable, because variadic templates do have *very*
> high chances to be introduced into C++0x.

"*very* high" is understating it. They are in the draft, and with a
working implementation already, there are chances of about nil +- zero
of getting removed for some reason.

> I find his extension proposal to allow a string-literal
> as an alternative argument of variadic non-type templates
> (of character type) quite interesting. This is IMO the
> first approach, where I would see any chance of acceptance
> on implementors side.
> Early proposals - which had no variadic templates available
> and usually reasoned about 'char const*' template parameters -
> lead to several problematic situations, which I do not
> see to exist for this proposal.

Yeah. This is a good idea. It doesn't take a lot of wording either:

Under [temp.arg.nontype], paragraph 1, add "a string literal" as
another element of the list. Replace paragraph 2 with "A string
literal shall only appear as the last template parameter (including
default parameters)." Add a new paragraph that says "A string literal
non-type template parameter is intepreted as a series of character
literals, each representing one character from the string (in order)
and becoming a separate template parameter, with a final '\0' as the
last parameter (so that the number of resultant character literals is
one greater than the number of characters in the string literal)." and
add some appropriate example. Probably didn't get the standardese
quite right, but the point is that it is quite a minor change.

This is a good idea. It's simple and maintains backwards-
compatibility. I don't know for sure, but I do not see this taking a
lot of extra work from implementors. It also makes writing code about
three times easier. I wholly endorse this proposal (not that my
endorsement probably means much).

Sean Hunt


-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 23 Posts in Topic:
String literal as template parameter?
Piotr Rak <piotr.rak@[  2008-04-12 12:09:19 
Re: String literal as template parameter?
Looney <hardy_melbourn  2008-04-13 12:45:53 
Re: String literal as template parameter?
Mathias Gaunard <loufo  2008-04-13 18:21:48 
Re: String literal as template parameter?
Brendan <catphive@[EMA  2008-04-13 18:21:13 
Re: String literal as template parameter?
=?ISO-8859-1?Q?Daniel_Kr=  2008-04-13 18:23:27 
Re: String literal as template parameter?
Sean Hunt <rideau3@[EM  2008-04-14 10:43:12 
Re: String literal as template parameter?
mark.zaytsev@[EMAIL PROTE  2008-04-14 13:13:15 
Re: String literal as template parameter?
Mathias Gaunard <loufo  2008-04-14 21:25:44 
Re: String literal as template parameter?
Alberto Ganesh Barbati &l  2008-04-14 21:24:25 
Re: String literal as template parameter?
Alberto Ganesh Barbati &l  2008-04-14 21:24:01 
Re: String literal as template parameter?
Alberto Ganesh Barbati &l  2008-04-14 21:24:40 
Re: String literal as template parameter?
Piotr Rak <piotr.rak@[  2008-04-15 12:43:13 
Re: String literal as template parameter?
=?ISO-8859-1?Q?Daniel_Kr=  2008-04-15 23:19:28 
Re: String literal as template parameter?
David Peklak <dpeklak@  2008-04-15 23:22:35 
Re: String literal as template parameter?
Alberto Ganesh Barbati &l  2008-04-16 11:43:13 
Re: String literal as template parameter?
Piotr Rak <piotr.rak@[  2008-04-17 19:35:09 
Re: String literal as template parameter?
Alberto Ganesh Barbati &l  2008-04-18 05:09:08 
Re: String literal as template parameter?
Sean Hunt <rideau3@[EM  2008-04-18 06:13:18 
Re: String literal as template parameter?
Bart van Ingen Schenau &l  2008-04-18 17:19:53 
Re: String literal as template parameter?
gpderetta <gpderetta@[  2008-04-18 17:20:48 
Re: String literal as template parameter?
Piotr Rak <piotr.rak@[  2008-04-19 01:39:07 
Re: String literal as template parameter?
Piotr Rak <piotr.rak@[  2008-04-19 02:01:57 
Re: String literal as template parameter?
Piotr Rak <piotr.rak@[  2008-04-19 02:02:03 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Jul 8 23:45:32 CDT 2008.