public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Philip Martin <philip@codematters.co.uk> To: paolo@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, Subject: Re: libstdc++/5133: Problems with toupper Date: Mon, 17 Dec 2001 08:06:00 -0000 [thread overview] Message-ID: <20011217160601.17499.qmail@sources.redhat.com> (raw) The following reply was made to PR libstdc++/5133; it has been noted by GNATS. From: Philip Martin <philip@codematters.co.uk> To: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, paolo@gcc.gnu.org, schmid@snake.iap.physik.tu-darmstadt.de, sebor@roguewave.com Cc: Subject: Re: libstdc++/5133: Problems with toupper Date: 17 Dec 2001 16:01:28 +0000 > #include <string> > #include <iostream> // does work, when this line is removed > #include <algorithm> > #include <cctype> > > int main() > { > std::string s("Hallo"); > std::transform (s.begin(), s.end(), s.begin(), std::tolower); > std::transform (s.begin(), s.end(), s.begin(), ::tolower); > } Using gcc the include of <iostream> brings in a declaration of the function template namespace std { template<class T> T tolower(T, const locale&); } and the include of <cctype> brings in the functions extern "C" int tolower(int); namespace std { using ::tolower; } [The global scope tolower function is a separate problem, but doesn't affect this PR.] Now, I believe you are trying to call the tolower function, rather than the tolower function template. I don't understand template argument deduction well enough to be able to say whether the compiler should work out that this is what you want, but you can tell it explicitly typedef std::string::iterator I; std::transform<I,I,int(*)(int)>transform(s.begin(),s.end(),s.begin(),std::tolower); This compiles with gcc 3.0.3 and gcc 3.1. However it doesn't address the "C"/"C++" linkage point mentioned by Martin. One can avoid that by using the function template, however using the function template is tricky because the second parameter is a reference. One would like to try // this won't work std::locale loc; std::transform(s.begin(),s.end().s.begin(), std::bind2nd(std::ptr_fun(std::tolower<char>),loc)); but this will suffer from the reference to a reference problem. If you wish to pursue this you should consider using the bind library from boost (http://www.boost.org) instead of std::bind2nd -- Philip
next reply other threads:[~2001-12-17 16:06 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2001-12-17 8:06 Philip Martin [this message] -- strict thread matches above, loose matches on Subject: below -- 2002-11-22 14:46 Pete Ratzlaff 2002-11-22 13:48 Martin Sebor 2002-11-22 5:43 Phil Edwards 2002-11-22 5:41 Pete Ratzlaff 2002-11-22 5:11 Pete Ratzlaff 2002-10-31 16:08 paolo 2002-06-27 23:14 Christopher Currie 2001-12-16 17:46 Martin Sebor 2001-12-16 15:46 Peter Schmid 2001-12-16 13:53 paolo 2001-12-16 13:16 Peter Schmid
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20011217160601.17499.qmail@sources.redhat.com \ --to=philip@codematters.co.uk \ --cc=gcc-prs@gcc.gnu.org \ --cc=paolo@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).