Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Why does std::basic_ios overload the unary negation operator?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Daniel Krügler  
View profile  
 More options Aug 12 2010, 9:02 am
Newsgroups: comp.lang.c++.moderated
From: Daniel Krügler <daniel.krueg...@googlemail.com>
Date: Thu, 12 Aug 2010 07:02:53 CST
Local: Thurs, Aug 12 2010 9:02 am
Subject: Re: Why does std::basic_ios overload the unary negation operator?
On 13 Jul., 15:01, sbi <non...@invalid.invalid> wrote:

> Hallo,

> The C++ IO streams' base class std::basic_ios defines operator void*()
> to return a safe bool indicating !fail() and operator!() to return fail().
> That makes me wonder why we need the operator!() at all. Certainly, !is
> would also work by implicitly calling operator void*() and negating its
> result.

> Am I missing something here or is it purely for (mistaken) historical
> reasons that std::basic_ios::operator!() is defined?

I have been told, that this additional declaration was added to
emphasize
the symmetry between the "true" case and it's negation, just as a
guide
for the reader, nothing more. To be fair, the idiom

operator void*

was rather new at this time and given this the deduction which syntax
support is provided by this feature is not immediately obvious. Other
than that there was no further technical reason to do so.
Nevertheless
you might still find some buggy compilers that don't get the
conversion
right without the additional operator!. As far as I remember
correctly, I
needed to provide operator! additionally for old Borland compilers.

HTH & Greetings from Bremen,

Daniel Krügler

--
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.