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

  • Home
  • SEARCH
  • 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 8318339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:56:05+00:00 2026-06-08T21:56:05+00:00

bool image_manager::contains_image(const std::string& filename) { return this->map_.count(filename); } Now the warning I get is:

  • 0
bool image_manager::contains_image(const std::string& filename)
{
    return this->map_.count(filename);
}

Now the warning I get is:

warning C4800: 'unsigned int' : forcing value to bool 'true' or 'false' (performance warning)

However since the return type of std::maps count() method is:

1 if an element with a key equivalent to x is found, or zero otherwise.

Hence it can be used pretty much like a boolean. So why exactly do I get this warning? In C++ integers can basically be used for boolean checks right? Hence 0 == false and 1 == true. So why does the compiler throw me a warning? I also tried using a static_cast like this:

return static_cast<bool>(this->map_.count(filename));

but I’m still getting the warning.

  • 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-06-08T21:56:08+00:00Added an answer on June 8, 2026 at 9:56 pm

    In general, an unsigned int is not a bool, hence the warning. Try:

    return this->map_.count(filename) > 0;
    

    instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

bool operator == (const MyString& left, const MyString& right) { if(left.value == right.value) return
I'm trying use this code to get image resolution from file bool GetImageSizeEx(const char
bool isValid = false; string username = someadmin; If( !String.IsNullOrEmpty(username) && !( username.IndexOf(admin) !=
bool operator()(Iterator it1, Iterator it2) const { return (*it1 < *it2); } Can someone
bool myBool = true; byte myByte; This conversion runs myByte = Convert.ToByte(myBool); This conversion
-(BOOL) textFieldShouldReturn:(UITextField*) theTextField{ [theTextField resignFirstResponder]; return YES; } it is not working....
I wrote some simple REST service that get Stream from client. This Stream is
bool hasDuplicate = false; int[] a = new int[] {1, 2, 3, 4}; int[]
BOOL utils::GetLogicDrivesByFreeSpace(LPTSTR pDrives) { TCHAR szBuff[257]; TCHAR chMaxDrive; DWORD dwLogicalDrives; ULARGE_INTEGER freeBytesAvaliable, maxFreeBytesAvaliable; ULARGE_INTEGER
- (BOOL) ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { CocosNode* spHead = [self getChildByTag:tagHead]; CocosNode* spBody

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.