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 22 of 23 Topic 9495 of 10096
Post > Topic >>

Re: String literal as template parameter?

by Piotr Rak <piotr.rak@[EMAIL PROTECTED] > Apr 19, 2008 at 02:01 AM

On Apr 18, 1:09 pm, Alberto Ganesh Barbati <AlbertoBarb...@[EMAIL PROTECTED]
>
wrote:
> Piotr Rak ha scritto:
> > The know deficiencies are:
> > - doesn't handle wide literals (should be easy),
> >   and unicode literals (not in gcc yet)
>
> I guess the simplest thing is to replace the literal with a sequence of
> char, char16_t, char32_t or wchar_t according to the string literal and
> let the usual promotion and conversion machinery to happen. Were you
> think of something different?
>
Not really, promotion allowed by standard should be allowed IMO.
Adding sup****t of wide string literals (L"") and wchar_t is 3-4 lines
of code more propably...
Just haven't been done yet :)
There is no Unicode literals in gcc, again i dont think that
sup****ting them will be hard.
> > - I should re****t error in case of "" or L""
>
> Do we need to diagnose an error in this situation? Would expanding to an
> empty sequence be impossible or unreasonable?
>
Technicaly it is not, it might expand to no characters.

However:

template <char...>  class Foo;
Foo<""> foo; // == Foo<> foo, Ok

//but:
Foo<"","",""> foo2; // is that Ok?

//also:
template <char> class Bar;
Bar<'a', ""> bar; // is it Ok?

It might be feature, in some cases, maybe some automated tool dumps ""
fo empty strings...
But i consider this code bit confusing, matter of taste...
So simplest solution would be just ban "".:)

Note that current version of patch has bug and will behave bad if
there is "" as template arguemnt, be warned!

> > - definitly needs testing (DejaGNU here I come!)
>
> If you need help, please contact me privately.
>
> > - and do***entation...
>
> If you need help, please contact me privately.
>
> > But overall, it should be enough to see how it feels.
>
Any help is highly welcome, I'll do that soon, thanks! :)

> > I am not sure if default template arguments should be sup****ted ie:
>
> > template <char... Chars_ = "Oink!">
> > struct Foo;
>
> > Comments welcome :)
>
> Ah! Good point. Currently default template-arguments cannot be specified
> for parameter packs. Although the feature is very appealing, I would
> leave it at that. Unless we make that a very special case, we would
> actually be forced to provide a meaning for the "equivalent" syntax:
>
>    template <char... Chars_ = 'O','i','n','k','!'>
>    struct Foo;
>
> and this would open a Pandora's box, IMHO.
>
> So I guess we should provide wording to disallow literals in default
> template-arguments, where replacement doesn't make sense.

Equivalent syntax is odd IMO, so that is good point.
I am not keen of providing special cases where we would allow syntax
with "", but disallow other one.
Also there is no syntax for non-character types, which would make this
feature 'asymmetric' in a language.

This is not essential, maybe we just should leave that out?

>
> > Note that, this was first time i've seen gcc sources...
>
> That means gcc sources are very well written or that you are very
> skilled or both ;)
>
I think the truth is, that sources are well do***ented, and
implementation of this feature was really trivial. :)
Almost half of patch is command line handling.
>
>
> Thanks! Now it's time to prepare a formal proposal. Let me help you with
> that.
>
Are you reading my mind?
In fact I was hoping, that someone will offer help with that.
My poor language skills could otherwise hurt this proposal. :)

Thanks again, for all your feedback and involvment. :)

Piotr

-- 
      [ 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 Oct 14 8:48:21 CDT 2008.