From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17540 invoked by alias); 17 Dec 2001 16:06:04 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 17503 invoked by uid 71); 17 Dec 2001 16:06:01 -0000 Date: Mon, 17 Dec 2001 08:06:00 -0000 Message-ID: <20011217160601.17499.qmail@sources.redhat.com> To: paolo@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Philip Martin Subject: Re: libstdc++/5133: Problems with toupper Reply-To: Philip Martin X-SW-Source: 2001-12/txt/msg00941.txt.bz2 List-Id: The following reply was made to PR libstdc++/5133; it has been noted by GNATS. From: Philip Martin 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 > #include // does work, when this line is removed > #include > #include > > 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 brings in a declaration of the function template namespace std { template T tolower(T, const locale&); } and the include of 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::transformtransform(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),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