Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Definition of logical true in C++?

Reply
Thread Tools

Definition of logical true in C++?

 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      01-21-2008
* Lars Uffmann:
> Alf P. Steinbach wrote:
>> In order to use the standard, you really need a searchable document.

> Valid point, the thing is, I need the standard as a reference for my
> department within the german space agency. A 1-workstation-license isn't
> really doing us much good.
>
>> I recommend downloading the latest draft from the committee pages
>> (it's in PDF format), and familiarizing yourself with use of that,
>> before paying hard cash for flaked dead trees.

>
> I am still having a hard time finding a pdf of the latest draft - C++98
> is what I need I guess - and the committee seems to be going out of its
> way to hide any download links very well deep down in the site... I'll
> keep searching..


I think it's funny how some people try to find out things in very
indirect ways. Instead of "Would you like to go the lastest James Bond
movie with me, tonight?" a series of vague questions designed to elicit
information about whether the person is likely to enjoy a James Bond
movie, of course without any mention of James Bond, and whether the
person has any other plans for the evening, so on. Huh, says I.

<url: http://www.google.com/search?q=latest+draft+of+c%2B%2B+standard>

Click on second main hit, where it says "ISO" in the title, then look
one or two paragraphs down on that page.


Cheers, & hth.,

- Alf

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
Reply With Quote
 
 
 
 
Lars Uffmann
Guest
Posts: n/a
 
      01-21-2008
Alf P. Steinbach wrote:
>> I am still having a hard time finding a pdf of the latest draft -
>> C++98 is what I need I guess - and the committee seems to be going out
>> of its way to hide any download links very well deep down in the
>> site... I'll keep searching..

> I think it's funny how some people try to find out things in very
> indirect ways. [..]


Thanks, but I meant what I said - I found it eventually
It was hard anyways, when you don't know that it's ISO 14882, and when
you expect a link to the document to contain the words "c++ standard" at
least

Best Regards,

Lars
 
Reply With Quote
 
 
 
 
Tomßs Ë h╔ilidhe
Guest
Posts: n/a
 
      01-21-2008
Lars Uffmann:


> Argl... That license agreement says "single computer only"... I guess
> I'll go for a printed book version Amazon, here I come...



I agree with Alf; I had a hard-copy of the Standard one time, it was a
mammoth of a thing and I could find no use for it. I threw it in the thrash
eventually.

You can always just type "14882:2003" into Google and hit "I'm Feeling
Lucky", brings you to exactly what you're looking for.

--
Tomßs Ë h╔ilidhe
 
Reply With Quote
 
Gerhard Fiedler
Guest
Posts: n/a
 
      01-21-2008
On 2008-01-21 05:06:41, Lars Uffmann wrote:

> If I define a function, that shall return -1 in case of error, and a
> positive value otherwise:
>
> int foo (int param) {
> if (outOfRange (param))
> return -1;
>
> return (param != 0);
> }


Just some food for thought... while this may "work", it may not always work
as intended

Looks to me as if this is a candidate for either an enum return value or an
exception thrown.

Gerhard
 
Reply With Quote
 
Juha Nieminen
Guest
Posts: n/a
 
      01-21-2008
Sebastian Redl wrote:
> However, the drafts of the standard are freely available


If I'm not completely mistaken, someone has even made man pages from
the C++ standard draft. Any idea where those could be available?
 
Reply With Quote
 
Erik Wikstr├Âm
Guest
Posts: n/a
 
      01-21-2008
On 2008-01-21 09:22, Lars Uffmann wrote:
> Sebastian Redl wrote:
>> Lars Uffmann wrote:
>>
>>> Ian Collins wrote:

>> http://webstore.ansi.org/RecordDetai...IEC+14882-2003
>>> Hmm - so the standard for THE programming language (imho) is not freely
>>> available?

>>
>> That's correct. ISO makes some money by selling the standard documents.

>
> Okay, I guess I don't mind... Thanks for the hint with the drafts.
> As for a hardcopy of the standard - all I seem to be able to find is
> http://www.amazon.com/C%2B%2B-Standa...0903548&sr=1-1
> - is there any other book that I've been overlooking?


That book is the latest version of the C++ standard. There might be some
other version of it (like paperback) but I doubt it.

--
Erik Wikstr├Âm
 
Reply With Quote
 
Erik Wikstr├Âm
Guest
Posts: n/a
 
      01-21-2008
On 2008-01-21 13:13, Gerhard Fiedler wrote:
> On 2008-01-21 05:06:41, Lars Uffmann wrote:
>
>> If I define a function, that shall return -1 in case of error, and a
>> positive value otherwise:
>>
>> int foo (int param) {
>> if (outOfRange (param))
>> return -1;
>>
>> return (param != 0);
>> }

>
> Just some food for thought... while this may "work", it may not always work
> as intended
>
> Looks to me as if this is a candidate for either an enum return value or an
> exception thrown.


Or at the very least using code that clearly states the intent:

int foo(int param) {
if (outOfRange(param))
return -1;
else if (param != 0)
return 1;
}

--
Erik Wikstr├Âm
 
Reply With Quote
 
Juha Nieminen
Guest
Posts: n/a
 
      01-21-2008
Erik Wikstr├Âm wrote:
> int foo(int param) {
> if (outOfRange(param))
> return -1;
> else if (param != 0)
> return 1;
> }


Not all paths return a value.
 
Reply With Quote
 
Erik Wikstr├Âm
Guest
Posts: n/a
 
      01-21-2008
On 2008-01-21 23:06, Juha Nieminen wrote:
> Erik Wikstr├Âm wrote:
>> int foo(int param) {
>> if (outOfRange(param))
>> return -1;
>> else if (param != 0)
>> return 1;
>> }

>
> Not all paths return a value.


Ooops. Forgot

else
return 0;

--
Erik Wikstr├Âm
 
Reply With Quote
 
Lars Uffmann
Guest
Posts: n/a
 
      01-23-2008
Erik Wikstr├Âm wrote:
> Or at the very least using code that clearly states the intent:
>
> int foo(int param) {
> if (outOfRange(param))
> return -1;
> else if (param != 0)
> return 1;
> }


Yes, I could do that - I was hoping to save some computing time on
avoiding the extra if-clause for param != 0 - just return the output of
that. And as Sebastian pointed out, in the standard, boolean true is
promoted to 1 - so I'm safe

Best Regards,

Lars
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[False,True] and [True,True] --> [True, True]????? bdb112 Python 45 04-29-2009 02:35 AM
does the logical expression return 1 ( if it is true ) absolutely? moosdau C Programming 6 12-29-2005 05:56 AM
Automagic determination of definition based on definition location. Jon Slaughter C++ 4 10-26-2005 05:00 PM
can a class definition inside another class's definition Jianli Shen C++ 1 03-13-2005 06:02 PM
help?: incomplete definition with complete definition in scope Ark C Programming 1 08-07-2004 04:21 PM



Advertisments