Hello,
i don't manage to use the tolower() function:
#include <algorithm>
#include <iostream>
#include <locale>
#include <string>
using std::cout;
using std::ctype;
using std::endl;
using std::locale;
using std::string;
using std::transform;
using std::use_facet;
typedef ctype< char > char_ctype_facet;
int
main()
{
locale loc("");
const char_ctype_facet& ct = use_facet< char_ctype_facet >(loc);
string str("Hello world.");
transform(str.begin(), str.end(),
str.begin(), ct.tolower);
cout << str << endl;
return 0;
}
$ g++ -W -Wall -std=c++98 -pedantic tolower.cc
tolower.cc: In function `int main()':
tolower.cc:24: error: no matching function for call to
`transform(__gnu_cxx::__normal_iterator<char*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >,
__gnu_cxx::__normal_iterator<char*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >,
__gnu_cxx::__normal_iterator<char*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >, <unknown type>)'
ct.tolower is <unknow type>
What am i doing wrong?
--
TheDD 11 3320
TheDD wrote: Hello,
i don't manage to use the tolower() function:
#include <algorithm> #include <iostream> #include <locale> #include <string>
using std::cout; using std::ctype; using std::endl; using std::locale; using std::string; using std::transform; using std::use_facet;
typedef ctype< char > char_ctype_facet;
int main() { locale loc(""); const char_ctype_facet& ct = use_facet< char_ctype_facet >(loc); string str("Hello world.");
transform(str.begin(), str.end(), str.begin(), ct.tolower);
Wouldn't
transform(str.begin(), str.end(), str.begin(), tolower);
do the trick? cout << str << endl; return 0; }
$ g++ -W -Wall -std=c++98 -pedantic tolower.cc tolower.cc: In function `int main()': tolower.cc:24: error: no matching function for call to `transform(__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, <unknown type>)'
ct.tolower is <unknow type>
What am i doing wrong?
Not sure.
Victor
Victor Bazarov wrote: [...] locale loc(""); const char_ctype_facet& ct = use_facet< char_ctype_facet >(loc); string str("Hello world.");
transform(str.begin(), str.end(), str.begin(), ct.tolower);
Wouldn't
transform(str.begin(), str.end(), str.begin(), tolower);
do the trick?
yes it does, thx a lot.
But in this case, i guess the used locale is "C". What can i do to use
another one?
--
TheDD
TheDD wrote: Victor Bazarov wrote:
[...]
locale loc(""); const char_ctype_facet& ct = use_facet< char_ctype_facet >(loc); string str("Hello world.");
transform(str.begin(), str.end(), str.begin(), ct.tolower);
Wouldn't
transform(str.begin(), str.end(), str.begin(), tolower);
do the trick?
yes it does, thx a lot.
But in this case, i guess the used locale is "C". What can i do to use another one?
Good question. Could you temporarily set it as "global one to use"
somehow? I am not that familiar with locales, as you probably figured
out by now...
V
Victor Bazarov wrote: Good question. Could you temporarily set it as "global one to use" somehow? I am not that familiar with locales, as you probably figured out by now...
Well i can use:
locale::global(locale(""));
but it's not really great. I'm going to read the docs one more time :)
--
TheDD
TheDD wrote: i don't manage to use the tolower() function:
#include <algorithm> #include <iostream> #include <locale> #include <string>
using std::cout; using std::ctype; using std::endl; using std::locale; using std::string; using std::transform; using std::use_facet;
typedef ctype< char > char_ctype_facet;
int main() { locale loc(""); const char_ctype_facet& ct = use_facet< char_ctype_facet >(loc); string str("Hello world.");
transform(str.begin(), str.end(), str.begin(), ct.tolower);
If you have to use a member function, try something like
std::transform(str.begin(), str.end(), str.begin(),
std::bind1st(std::mem_fun(&ctype<char>::tolower), ct));
I couldn't get it to compile, but dig in that direction. cout << str << endl; return 0; }
$ g++ -W -Wall -std=c++98 -pedantic tolower.cc tolower.cc: In function `int main()': tolower.cc:24: error: no matching function for call to `transform(__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, <unknown type>)'
ct.tolower is <unknow type>
What am i doing wrong?
To use a member function, you need 'mem_fun'.
Victor
On Fri, 28 May 2004 22:18:50 +0200, TheDD <pa*********@pas.de.spam.fr>
wrote: Hello,
i don't manage to use the tolower() function:
#include <algorithm> #include <iostream> #include <locale> #include <string>
#include <cstdlib> using std::cout; using std::ctype; using std::endl; using std::locale; using std::string; using std::transform; using std::use_facet;
typedef ctype< char > char_ctype_facet;
int main() { locale loc(""); const char_ctype_facet& ct = use_facet< char_ctype_facet >(loc); string str("Hello world.");
transform(str.begin(), str.end(), str.begin(), ct.tolower);
cout << str << endl; return 0; }
$ g++ -W -Wall -std=c++98 -pedantic tolower.cc tolower.cc: In function `int main()': tolower.cc:24: error: no matching function for call to `transform(__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, <unknown type>)'
ct.tolower is <unknow type>
What am i doing wrong?
You need to include a library that includes tolower.
rossum
(Who has done the same sort of thing more often than he cares to
remember.)
--
The Ultimate Truth is that there is no Ultimate Truth
Le 28/05/2004 à 23:29:31, rossum <ro******@coldmail.com> a écrit: On Fri, 28 May 2004 22:18:50 +0200, TheDD <pa*********@pas.de.spam.fr> wrote:
Hello,
i don't manage to use the tolower() function:
#include <algorithm> #include <iostream> #include <locale> #include <string>
#include <cstdlib>
using std::cout; using std::ctype; using std::endl; using std::locale; using std::string; using std::transform; using std::use_facet;
typedef ctype< char > char_ctype_facet;
int main() { locale loc(""); const char_ctype_facet& ct = use_facet< char_ctype_facet >(loc); string str("Hello world.");
transform(str.begin(), str.end(), str.begin(), ct.tolower);
cout << str << endl; return 0; }
$ g++ -W -Wall -std=c++98 -pedantic tolower.cc tolower.cc: In function `int main()': tolower.cc:24: error: no matching function for call to `transform(__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, <unknown type>)'
ct.tolower is <unknow type>
What am i doing wrong?
You need to include a library that includes tolower.
rossum (Who has done the same sort of thing more often than he cares to remember.)
same error message, doesn't seem to be that.
--
TheDD
Victor Bazarov wrote: If you have to use a member function, try something like
std::transform(str.begin(), str.end(), str.begin(), std::bind1st(std::mem_fun(&ctype<char>::tolower), ct));
I couldn't get it to compile, but dig in that direction.
Well i don't have a member function.
This works:
#include <algorithm>
#include <iostream>
#include <locale>
#include <string>
#include <functional>
using std::cout;
using std::endl;
using std::locale;
using std::string;
using std::transform;
using std::bind2nd;
struct s : std::binary_function< char, locale, char >
{
char operator ()(char c, const locale & loc) const
{
/* use:
* template<typename CharT>
* CharT std::tolower ( CharT c,
* const locale & __loc
* )
*/
return std::tolower(c, loc);
}
};
int
main()
{
locale loc("");
string str("Hello world.");
// use s operator ()
transform(str.begin(), str.end(),
str.begin(), bind2nd(s(), loc));
cout << str << endl;
return 0;
}
but is really not classy.
--
TheDD
"TheDD" <pa*********@pas.de.spam.fr> wrote... Victor Bazarov wrote:
If you have to use a member function, try something like
std::transform(str.begin(), str.end(), str.begin(), std::bind1st(std::mem_fun(&ctype<char>::tolower), ct));
I couldn't get it to compile, but dig in that direction.
Well i don't have a member function.
If you didn't, why were you trying to say
ct.tolower
? Isn't the notation '.' meant for member access? I must
be missing something here...
V
"TheDD" <pa*********@pas.de.spam.fr> wrote in message
news:c9**********@news-reader5.wanadoo.fr... Hello,
i don't manage to use the tolower() function:
#include <algorithm> #include <iostream> #include <locale> #include <string>
using std::cout; using std::ctype; using std::endl; using std::locale; using std::string; using std::transform; using std::use_facet;
typedef ctype< char > char_ctype_facet;
int main() { locale loc(""); const char_ctype_facet& ct = use_facet< char_ctype_facet >(loc); string str("Hello world.");
transform(str.begin(), str.end(), str.begin(), ct.tolower);
cout << str << endl; return 0; }
$ g++ -W -Wall -std=c++98 -pedantic tolower.cc tolower.cc: In function `int main()': tolower.cc:24: error: no matching function for call to `transform(__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, <unknown type>)'
ct.tolower is <unknow type>
What am i doing wrong?
I am not sure, but it might be related to:
Bug#144409: g++-3.0: does not support transform(begin,end,begin,tolower)
idiom http://lists.debian.org/debian-gcc/2.../msg00092.html -- TheDD
Le 29/05/2004 à 02:11:45, Victor Bazarov <v.********@comAcast.net> a
écrit: If you have to use a member function, try something like
std::transform(str.begin(), str.end(), str.begin(), std::bind1st(std::mem_fun(&ctype<char>::tolower), ct));
I couldn't get it to compile, but dig in that direction.
Well i don't have a member function.
If you didn't, why were you trying to say
ct.tolower
? Isn't the notation '.' meant for member access? I must be missing something here...
My mistake, sorry :p
--
TheDD This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: qazmlp |
last post by:
I was using the following code to convert the string to
lowercase.
string foo = "Some Mixed Case Text";
transform(foo.begin(), foo.end(), foo.begin(), tolower);
I thought the above code is...
|
by: David Rubin |
last post by:
I get an error when I compile the following code:
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
using namespace std;
string&
|
by: Ahsan |
last post by:
Hi All,
I am having prolems with converting upper case characters to lower
case in Unix's C. I saw the man pages and "tolower" function does it.
But in my case its not working.
My code is as...
|
by: Daniel Aarno |
last post by:
As far as I can tell the locale header should provide a tolower function
however the following failes for me under gcc 3.4.
transform(begin, end, begin2, std::tolower);
with an error that the...
|
by: Eric Lilja |
last post by:
Hello, consider this program:
#include <iostream>
#include <algorithm>
#include <string>
#include <cctype>
int
main()
{
std::string s = "HEJ";
|
by: Ben Dewey |
last post by:
Project:
----------------------------
I am creating a HTTPS File Transfer App using ASP.NET and C#. I am
utilizing ActiveDirectory and windows security to manage the
permissions. Why reinvent...
|
by: Anthony Williams |
last post by:
Hi gang,
This one looks like a bug :o(
As you may or may not know, setting session management in web.config to use
cookieless sessions causes the ASP.NET runtime to munge a session ID into...
|
by: Faray |
last post by:
Hello, this is my first post, so hopefully I am posting this in the right place.
Hopefully someone will be able to help me out with my problem here it is:
I need to make a program that ask a...
|
by: Soumen |
last post by:
I wanted convert a mixed case string to a lower case one. And I tried
following code:
std::transform(mixedCaseString.begin(), mixedCaseString::end(),
mixedCaseString.begin(),...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |