Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #10921
| From | Nobody <nobody@nowhere.com> |
|---|---|
| Subject | Re: What is valid std::strstr()'s signature? |
| Date | 2011-10-17 13:52 +0100 |
| Message-Id | <pan.2011.10.17.12.52.54.970000@nowhere.com> |
| Newsgroups | comp.lang.c++ |
| References | <cde857e0-4f39-4a8e-9095-78cf74530a92@w5g2000yqw.googlegroups.com> |
| Organization | Zen Internet |
On Mon, 17 Oct 2011 03:50:59 -0700, Alex Vinokur wrote: > What is valid std::strstr()'s signature? This (21.7p7): > const char * strstr ( const char * str1, const char * str2 ); > char * strstr ( char * str1, const char * str2 ); > HP-UX B.11.23 U ia64 > /usr/include/string.h: This is the ISO C definition: > extern char *strstr(const char *, const char *); C doesn't have overloaded functions, so there can only be a single prototype. The strstr() function doesn't modify either string (hence the "const" on the argument types), but the return value (if not NULL) is a pointer into the target string specified by the first argument. If the target string can safely be modified, then it's safe to modify it via the returned pointer (hence no "const" on the return type). If the target string should not be modified, then it's not safe to modify it via the returned pointer either. The C++ definition uses overloading to encode these rules.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
What is valid std::strstr()'s signature? Alex Vinokur <alex.vinokur@gmail.com> - 2011-10-17 03:50 -0700
Re: What is valid std::strstr()'s signature? Nobody <nobody@nowhere.com> - 2011-10-17 13:52 +0100
Re: What is valid std::strstr()'s signature? Alex Vinokur <alex.vinokur@gmail.com> - 2011-10-17 06:20 -0700
Re: What is valid std::strstr()'s signature? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-10-17 10:34 -0400
Re: What is valid std::strstr()'s signature? Leigh Johnston <leigh@i42.co.uk> - 2011-10-17 15:39 +0100
Re: What is valid std::strstr()'s signature? Marc <marc.glisse@gmail.com> - 2011-10-17 16:23 +0000
csiph-web