![]() |
Definition of logical true in C++?
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); } can I rely on this code always working, or is it possible that the return statement produces a -1 also, on a specific compiler / OS? Is this defined somewhere? And if so, where in the standard? Best Regards, Lars |
Re: Definition of logical true in C++?
Lars Uffmann wrote:
> can I rely on this code always working, or is it possible that the > return statement produces a -1 also, on a specific compiler / OS? > Is this defined somewhere? And if so, where in the standard? As defined by 4.5/4, boolean true is promoted to 1, boolean false to 0. -- Sebastian Redl |
Re: Definition of logical true in C++?
Sebastian Redl wrote:
> As defined by 4.5/4, boolean true is promoted to 1, boolean false to 0. Thanks, that's all I needed to know - though I just noticed that there's no easily found online version of the C++ standards - are you able to point me to one? Best Regards, Lars |
Re: Definition of logical true in C++?
Lars Uffmann wrote:
> Sebastian Redl wrote: >> As defined by 4.5/4, boolean true is promoted to 1, boolean false to 0. > > Thanks, that's all I needed to know - though I just noticed that there's > no easily found online version of the C++ standards - are you able to > point me to one? > http://webstore.ansi.org/RecordDetai...IEC+14882-2003 -- Ian Collins. |
Re: Definition of logical true in C++?
Ian Collins wrote:
> http://webstore.ansi.org/RecordDetai...IEC+14882-2003 Hmm - so the standard for THE programming language (imho) is not freely available? Not that I mind ordering a copy... just wondrin'... *headscratch* Thank you :) Lars |
Re: Definition of logical true in C++?
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. However, the drafts of the standard are freely available (search for C++ last public draft) and differ from the final version only in some rather small issues. (The biggest difference I've found so far is in the rules concerning reinterpret_cast.) -- Sebastian Redl |
Re: Definition of logical true in C++?
Lars Uffmann wrote:
> Ian Collins wrote: >> http://webstore.ansi.org/RecordDetai...IEC+14882-2003 > Not that I mind ordering a copy... just wondrin'... *headscratch* Argl... That license agreement says "single computer only"... I guess I'll go for a printed book version :) Amazon, here I come... Regards, Lars |
C++ Standard hardcopy (was: Re: Definition of logical true in C++?)
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? Thanks! Lars |
Re: Definition of logical true in C++?
* Lars Uffmann:
> Lars Uffmann wrote: >> Ian Collins wrote: >>> http://webstore.ansi.org/RecordDetai...IEC+14882-2003 >> >> Not that I mind ordering a copy... just wondrin'... *headscratch* > > Argl... That license agreement says "single computer only"... I guess > I'll go for a printed book version :) Amazon, here I come... In order to use the standard, you really need a searchable document. Without searchability, all you have is a pile of expensive paper, because relevant paragraphs for some issue are generally scattered throughout the standard -- because the standard has evolved from a relatively small document, keeping the document structure while adding in new stuff and amendning existing text here and there (it really needs quite a bit of refactoring! :-) ). 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. 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? |
Re: Definition of logical true in C++?
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.. Best Regards, Lars |
| All times are GMT. The time now is 06:00 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.