Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6597585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:13:41+00:00 2026-05-25T18:13:41+00:00

//for( unsigned int i=0; i < c.size(); i++ ) tolower( c[i] ); for_each( c.begin(),

  • 0
//for( unsigned int i=0; i < c.size(); i++ ) tolower( c[i] );
for_each( c.begin(), c.end(), tolower );

I am trying to use a for_each loop in place of the for loop for an assignment.

I am unsure why I am getting this error message:

In function âvoid clean_entry(const std::string&, std::string&)â:
prog4.cc:62:40: error: no matching function for call to âfor_each(std::basic_string<char>::iterator, std::basic_string<char>::iterator, <unresolved   overloaded function type>)â
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:13:42+00:00Added an answer on May 25, 2026 at 6:13 pm

    Write:

    for_each( c.begin(), c.end(), ::tolower );
    

    Or :

    for_each( c.begin(), c.end(), (int(*)(int))tolower);
    

    I’ve faced this problem so many times that I’m tired of fixing this in my code, as well as in others’ code.

    Reason why your code is not working : there is another overloaded function tolower in the namespace std which is causing problem when resolving the name, because the compiler is unable to decide which overload you’re referring to, when you simply pass tolower 1. That is why the compiler is saying unresolved overloaded function type in the error message, which indicates the presence of overload(s).

    So to help the compiler in resolving to the correct overload, you’ve to cast tolower as

    (int (*)(int))tolower
    

    then the compiler gets the hint to select the global tolower function, which in other ways, can be used by writing ::tolower.

    1. I guess you’ve written using namespace std in your code. I would also suggest you to not to do that. Use fully-qualified names in general.


    By the way, I think you want to transform the input string into lower case, if so, then std::for_each wouldn’t do that. You’ve to use std::transform function as:

    std::string out;
    std::transform(c.begin(), c.end(), std::back_inserter(out), ::tolower);
    //out is output here. it's lowercase string.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a size function like this: size(void *p,int size); Which would
Unsigned int into a short and back. Is this possible? How to do it
This is the code: unsigned int number; FILE* urandom = fopen(/dev/urandom, r); if (urandom)
I've this class namespace baseUtils { template<typename AT> class growVector { int size; AT
I'm trying to compute the maximal weight in a heap with this function: unsigned
struct MyClass { int foo () { return 0; } }; unsigned int size
I'm making a vector<bool> implementation. I save an unsigned int and use bitwise operations
So you can do this: void foo(const int * const pIntArray, const unsigned int
kay so this void printPacketBuffer(void *buffer, unsigned int length) { unsigned int i=0; char
unsigned int *pMessageLength, MessageLength; char *pszParsePos; ... //DATA into pszParsePos ... printf(\nMessage Length\nb1: %d\nb2:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.