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 3437388
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:03:32+00:00 2026-05-18T08:03:32+00:00

When answering this question I made some research which really confuses me. I noticed

  • 0

When answering this question I made some research which really confuses me.

I noticed that two ifstreams that succesfully open are not equal but two ifstreams that fail are.
At first i checked cplusplus.com. The operator ! returns the status of the badbit and failbit. I think that the opposite of this would still be to return the status of these two bits, but flipped.

  • Wrong, because two succesful calls are not equal.

So then I figured it was an operator bool somewhere that would return something. So I tried to backtrack from ifstream and found the istream::operator bool(), which is returning _Ok.

  • Still wrong however, this doesn’t seem to be called at all (and couldn’t be, since the two successful calls are still not equal).

So I changed my approach and checked the disassembly from Visual Studio. And what do I find?
if (file0 != file1) { doesn’t call the operator bool(), but rather the operator void* () (or really __imp_std::ios_base::operator void *).

So the questions I have are..

  • Shouldn’t any operator bool () found be called before trying to casting it to pointer values?
  • Is it some operator bool() I missed that in turn is calling the operator void* ?
  • Is this some optimizing that I don’t understand?

  • Or am I completely wrong in that C++ actually thinks that void* is a better match than bool in this comparison?

  • 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-18T08:03:33+00:00Added an answer on May 18, 2026 at 8:03 am

    1.) You cannot overload multiple times but with different return types.
    2.) Yes, operator! returns the badbit/failbit, but operator! is something entirely different from operator!=, which is the one you are using.

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

Sidebar

Related Questions

While answering this question DOM parser: remove certain attributes only I noticed that some
In answering this question , I suggested that the OP open a stream at
While answering this question I noticed that I have never come across any property
Sorry this is a basic question, but all my research just barely missed answering
This is a complex question, please consider carefully before answering. Consider this situation. Two
Hi folks would really appreciate your help in answering this rather involved question. Please
In answering this question please take into consideration the fact that I'm an Android
In answering this question , I came across a situation that I don't understand.
I'll be answering this question To my great surprise, I discovered that, after using
In answering this question ( https://stackoverflow.com/questions/352317/c-coding-question#352327 ), it got me wondering... Is there any

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.