According to Geoff Hutchison:
> [EMAIL PROTECTED] wrote:
> >> ! char *input_str;
> >> ! strcpy(input_str, (optind < ac ? av[optind] : ""));
> >> ! cgi input(input_str);
> >>
> >
> > I'd say
> >
> > String input_str(optind < ac ? av[optind] : "");
> > cgi input(input_str);
>
> No can do. This discards the const as well. We don't have a const char *
> constructor, and even if we did, we'd have to do a copy somewhere. (I'm
> not so sure I want to add a String(const char*) just for this purpose
> either.
If that would give a warning, then wouldn't these two constructs also give
warnings?
String foo("bar");
String abc = "xyz";
If they do, aren't we going to get warnings all over the place? If they
don't, then I'm not clear on what discards the const, and what doesn't.
> I agree with the standard--you don't want to to let people mess around
> with const variables. But you have to be able to discard it somehow! It
> seems the only safe way is to use strcpy or equivalent.
Unfortunately, the standard came in pretty late, after behaviour patterns
were well established. It's hard to change old habits when you're used
to simply declaring function arguments as char *. The standard is kinda
confusing too. I'm still not clear on the difference between const
char *foo and char * const foo, and when to use which. Eventually,
we should declare all our methods and functions appropriately - if
it doesn't change the data that it's passed, it should include the
appropriate const in its declaration. Until then, I think we'll have
to deal with more kludges like this one.
--
Gilles R. Detillieux E-mail: <[EMAIL PROTECTED]>
Spinal Cord Research Centre WWW: http://www.scrc.umanitoba.ca/~grdetil
Dept. Physiology, U. of Manitoba Phone: (204)789-3766
Winnipeg, MB R3E 3J7 (Canada) Fax: (204)789-3930
------------------------------------
To unsubscribe from the htdig3-dev mailing list, send a message to
[EMAIL PROTECTED] containing the single word "unsubscribe" in
the SUBJECT of the message.