473,795 Members | 2,766 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using tolower in transform

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_face t;

int
main()
{
locale loc("");
const char_ctype_face t& ct = use_facet< char_ctype_face t >(loc);
string str("Hello world.");

transform(str.b egin(), 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(__gn u_cxx::__normal _iterator<char* , std::basic_stri ng<char,
std::char_trait s<char>, std::allocator< char> > >,
__gnu_cxx::__no rmal_iterator<c har*, std::basic_stri ng<char,
std::char_trait s<char>, std::allocator< char> > >,
__gnu_cxx::__no rmal_iterator<c har*, std::basic_stri ng<char,
std::char_trait s<char>, std::allocator< char> > >, <unknown type>)'

ct.tolower is <unknow type>

What am i doing wrong?

--
TheDD
Jul 22 '05
11 3364
"TheDD" <pa*********@pa s.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_face t;

int
main()
{
locale loc("");
const char_ctype_face t& ct = use_facet< char_ctype_face t >(loc);
string str("Hello world.");

transform(str.b egin(), 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(__gn u_cxx::__normal _iterator<char* , std::basic_stri ng<char,
std::char_trait s<char>, std::allocator< char> > >,
__gnu_cxx::__no rmal_iterator<c har*, std::basic_stri ng<char,
std::char_trait s<char>, std::allocator< char> > >,
__gnu_cxx::__no rmal_iterator<c har*, std::basic_stri ng<char,
std::char_trait s<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,tolo wer)
idiom
http://lists.debian.org/debian-gcc/2.../msg00092.html

--
TheDD

Jul 22 '05 #11
Le 29/05/2004 à 02:11:45, Victor Bazarov <v.********@com Acast.net> a
écrit:
If you have to use a member function, try something like

std::transform( str.begin(), str.end(), str.begin(),
std::bind1st(st d::mem_fun(&cty pe<char>::tolow er), 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
Jul 22 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
31871
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 portable. But, the following page has a different view on this: http://lists.debian.org/debian-gcc/2002/debian-gcc-200204/msg00092.html
13
6032
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&
3
1821
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 follows: ============================================================ gets ( input ); sscanf(input, "%s", Cmd); for( p = 0; p < strlen( Cmd ); p++ )/* Changing all input to lower
2
1838
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 last arg is of unknown type. Any ideas on why?
4
3254
by: Eric Lilja | last post by:
Hello, consider this program: #include <iostream> #include <algorithm> #include <string> #include <cctype> int main() { std::string s = "HEJ";
9
10906
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 the wheel, right? Everything so far is working well with the Active Directory. The problem I am having is with adding File Permissions to a directory. I am currently using some code courtesy of "Willy Denoyette "
10
7932
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 the URL, in the format http://yourapplicationpath/(Session.SessionID)/... which saves numerous headaches when it comes to storing state across page requests and sessions.
5
2232
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 user to input a word. However when they input that word I need to convert the word to all lowercase letters so it can do a serach. This is my problem: Every time I try to use tolower it gives me an error "Cannot convert parameter 1 from...
13
3003
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(), std::ptr_fun(tolower)); Even though I's including cctype and algorithm, I's getting compiler (g ++ 3.3.6) error: no matching function for call to `ptr_fun(<unknown type>)'
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10436
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10163
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3722
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.