Tuesday, May 1, 2018

Digest for comp.lang.c++@googlegroups.com - 17 updates in 6 topics

Robert Wessel <robertwessel2@yahoo.com>: Apr 30 11:06PM -0500

On Mon, 30 Apr 2018 15:09:37 GMT, scott@slp53.sl.home (Scott Lurndal)
wrote:
 
 
>And here I always though it was to match 80-column cards. And note
>that printers were generally 132 columns before consumer (cheap)
>printers became widely available.
 
 
A major use case, perhaps *the* major use case for printers in the
early days of computing was to present data in a (more-or-less)
tabular format. That has always lent itself to wider presentations.
Just look at many of the old-fashioned paper accounting ledger books.
But that's not text-like data. Interestingly, the 17x11 inch paper
those printers spent so much time banging on is actually known as a
"ledger size" page (similar to the common 8.5x11 being a "letter size"
page).
 
The US letter size, and the similar international standard size (aka
A4), formats long predate modern computers, and all accommodate about
80 characters with a reasonably sized font. Of course smaller fonts
have always existed, and you could even fairly easily get typewriters
with smaller fonts (usually called an "elite" font, or some-such), but
they were fairly rare, and tended to be used more in application where
the harder to read font was a worthwhile tradeoff for the increased
presentation width.
legalize+jeeves@mail.xmission.com (Richard): May 01 05:38PM

[Please do not mail me a copy of your followup]
 
"James R. Kuyper" <jameskuyper@verizon.net> spake the secret code
>about 80 characters puts excess strain on your eye muscles - which is
>why 80 characters was a popular choice for both printers and display
>screens.
 
The ergonomic case is valid, but it isn't the historical reason for
display screens at least. Many early terminals were 32 or 40 characters
per line and by the mid 60s the switch to 80 characters per line was the
defacto standard. Mostly this is due to the cost of memory, character
generators, refresh circuitry and the available resolution of cheap
CRT tubes used in black and white televisions as a ready supply of CRT
tubes for display terminals.
 
At some point, it became a selling point to support 132 columns for line
in display terminals so that the display matches the printed output.
However, most terminals displayed pretty crappy looking glyphs for
characters in 132 column mode. Mode 80 column terminals used pretty
crappy looking glyphs to begin with in order to reduce the cost and
complexity of character generation and refresh circuitry. A notable
exception were terminals produced by Hewlett-Packard, where they had a
bunch of tricks to get really smooth looking characters. Here are
some images for reference:
<http://hpmuseum.net/images/2645AScreen-35.jpg>
<http://hpmuseum.net/images/2622AScreen-30.jpg>
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Terminals Wiki <http://terminals-wiki.org>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
Vir Campestris <vir.campestris@invalid.invalid>: May 01 09:57PM +0100

On 30/04/2018 10:02, Jouko Koski wrote:
> vga projectors out there. Some people may be visually impaired or just
> prefer to use the ample horizontal space for placing the working
> windows side by side.
 
I haven't seen anyone print any code in years (and in any case a quick
count on the nearest bit of paper indicates a line length of ~120 on an
A4 newsletter). I don't want my company secrets out on smartphones. We
don't have any VGA projectors, and don't put code up on the projectors
we have anyway. Visually impaired is a fair point - but there aren't
many visually impaired programmers. I've only met one in my entire
career. Why would I affect everyone else's productivity for the sake of
the minority? Just buy a decent 4k TV for the one with the eye problems.
I just checked my screen width - I can get about 200 chars in the window
I use here, even given the subsidiary windows beside it. And this
monitor is smaller than anything I use professionally. 200 probably is a
bit long...
 
> printable characters in a source file (or in any text, for the matter!)
> with X characters, and assess if the pattern still communicates
> structure, function, and intent.
 
That was exaggerated to make a point.
 
>> Apparently the Linux kernel standard is to stop excessive nesting. so
>> why doesn't it limit nesting instead?
 
> Well, it does, doesn't it?
 
Yes, but indirectly. You can have longer meaningful parts in lines at
the outer nesting levels. Which to me is just weird. A direct limit on
nesting would make sense to me.
 
Andy
legalize+jeeves@mail.xmission.com (Richard): May 01 09:34PM

[Please do not mail me a copy of your followup]
 
Vir Campestris <vir.campestris@invalid.invalid> spake the secret code
 
>Visually impaired is a fair point - but there aren't
>many visually impaired programmers.
 
It happens to everyone if they live long enough.
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Terminals Wiki <http://terminals-wiki.org>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
rick.c.hodgin.rick.c.hodgin@gmail.com: May 01 11:34AM -0700

This post describes the life timeline of each person on Earth. People are
divided into two camps: saved, unsaved. This relates whether or not a
person receives forgiveness from Jesus Christ for their sin ... or not.
 
When a person is born:
 
You are ALREADY dead in sin. You ONLY know what your flesh feeds you. We
are more than our flesh. Eternal life is life of the spirit, not the flesh,
and because of sin we have ALREADY been judged and are no longer alive in
our spirit.
 
Below is the life cycle of each of us, for we are more than this flesh, and
we continue on after we leave this world:
 
Eventual Believer Non-believer
--------------------------------------- ---------------------------------
FLESH SPIRIT == FLESH SPIRIT
===== ====== == ===== ======
| (dead) == | (dead)
| || == | ||
(born) | (dead) == (born) | (dead)
|| | || == || | ||
(grow) | (dead) == (grow) | (dead)
|| | || == || | ||
+-------------------------------------+ == || | (dead)
| (accepts Christ as (born again) | == || | ||
| Savior and Lord) (alive) | == || | (dead)
| || || | == || | ||
| (live, work) (alive) | == (live, work) | (dead)
| || || | == || | ||
| (age) (alive) | == (age) | (dead)
| || || | == || | ||
| (die) (alive) | == (die) | (dead)
| || | == || | ||
| Note: Once the (rewards) | == (sleep) | (dead)
| believer accepts || | == | ||
| forgiveness of (alive with | == | (judgment)
| their sin, then God forever)| == | ||
| the flesh and || | == | (cast into
| the spirit are (Heaven) | == | Hell forever)
| one in the new || | == | ||
| believer's life. (alive) | == | (torment)
| || | == | ||
| God's Holy Spirit (joy) | == | (death)
| guides us in our || | == | ||
| flesh / natural (alive) | == | (torment)
| life, as a down || | == | ||
| payment of the (peace) | == | (death)
| full live we || | == | ||
| receive in His (alive) | == | (torment)
| Kingdom in all || | == | ||
| of eternity. (happiness) | == | (death)
| || | == | ||
| (alive) | == | (torment)
| || | == | ||
| (learning) | == | (death)
| || | == | ||
| (alive) | == | (torment)
| || | == | ||
| (growing) | == | (death)
| || | == | ||
| (alive) | == | (torment)
| || | == | ||
+-------------------------------------+ ---------------------------------

And it goes on. For those alive with Christ, exploring the universe,
learning ever more about His Kingdom. How much is there to know? How
deep is an infinite God? How vast is the Kingdom He's created here for
us to explore?
 
I would save people from that quick end of being cast into Hell and being
tormented forever, by teaching them to come to Jesus Christ and ask for
forgiveness for their sin.
 
You do have sin.
You do need forgiveness.
Jesus is ready to forgive you.
Ask Him to forgive you and make your spirit alive forever.
 
For those who are only born once (of the flesh), you will die twice
(once of the flesh, once of the spirit). But for those who are born
twice (once of the flesh, once of the spirit), you will only die once.
 
Both will receive an eternal body after we leave this world. But the
one who dies with their sin remaining charged to them will be cast into
Hell, because they never came to accept the truth, never came to accept
that Jesus Christ is truth, that He cleanses us from all unrighteousness.
 
Your eternal fate depends ENTIRELY upon what YOU do with Jesus Christ.
Ignore Him or accept His free offer of salvation ... the choice is yours.
 
--
Rick C. Hodgin
rick.c.hodgin.rick.c.hodgin@gmail.com: May 01 11:30AM -0700

This post describes the life timeline of each person on Earth. People are
divided into two camps: saved, unsaved. This relates whether or not a
person receives forgiveness from Jesus Christ for their sin ... or not.
 
When a person is born:
 
You are ALREADY dead in sin. You ONLY know what your flesh feeds you. We
are more than our flesh. Eternal life is life of the spirit, not the flesh,
and because of sin we have ALREADY been judged and are no longer alive in
our spirit.
 
Below is the life cycle of each of us, for we are more than this flesh, and
we continue on after we leave this world:
 
Eventual Believer Non-believer
--------------------------------------- ---------------------------------
FLESH SPIRIT == FLESH SPIRIT
===== ====== == ===== ======
| (dead) == | (dead)
| || == | ||
(born) | (dead) == (born) | (dead)
|| | || == || | ||
(grow) | (dead) == (grow) | (dead)
|| | || == || | ||
+-------------------------------------+ == || | (dead)
| (accepts Christ as (born again) | == || | ||
| Savior and Lord) (alive) | == || | (dead)
| || || | == || | ||
| (live, work) (alive) | == (live, work) | (dead)
| || || | == || | ||
| (age) (alive) | == (age) | (dead)
| || || | == || | ||
| (die) (alive) | == (die) | (dead)
| || | == || | ||
| Note: Once the (rewards) | == (sleep) | (dead)
| believer accepts || | == | ||
| forgiveness of (alive with | == | (judgment)
| their sin, then God forever)| == | ||
| the flesh and || | == | (cast into
| the spirit are (Heaven) | == | Hell forever)
| one in the new || | == | ||
| believer's life. (alive) | == | (torment)
| || | == | ||
| God's Holy Spirit (joy) | == | (death)
| guides us in our || | == | ||
| flesh / natural (alive) | == | (torment)
| life, as a down || | == | ||
| payment of the (peace) | == | (death)
| full live we || | == | ||
| receive in His (alive) | == | (torment)
| Kingdom in all || | == | ||
| of eternity. (happiness) | == | (death)
| || | == | ||
| (alive) | == | (torment)
| || | == | ||
| (learning) | == | (death)
| || | == | ||
| (alive) | == | (torment)
| || | == | ||
| (growing) | == | (death)
| || | == | ||
| (alive) | == | (torment)
| || | == | ||
+-------------------------------------+ ---------------------------------

And it goes on. For those alive with Christ, exploring the universe,
learning ever more about His Kingdom. How much is there to know? How
deep is an infinite God? How vast is the Kingdom He's created here for
us to explore?
 
I would save people from that quick end of being cast into Hell and being
tormented forever, by teaching them to come to Jesus Christ and ask for
forgiveness for their sin.
 
You do have sin.
You do need forgiveness.
Jesus is ready to forgive you.
Ask Him to forgive you and make your spirit alive forever.
 
For those who are only born once (of the flesh), you will die twice
(once of the flesh, once of the spirit). But for those who are born
twice (once of the flesh, once of the spirit), you will only die once.
 
Both will receive an eternal body after we leave this world. But the
one who dies with their sin remaining charged to them will be cast into
Hell, because they never came to accept the truth, never came to accept
that Jesus Christ is truth, that He cleanses us from all unrighteousness.
 
Your eternal fate depends ENTIRELY upon what YOU do with Jesus Christ.
Ignore Him or accept His free offer of salvation ... the choice is yours.
 
--
Rick C. Hodgin
rick.c.hodgin.rick.c.hodgin@gmail.com: May 01 11:31AM -0700

This post describes the life timeline of each person on Earth. People are
divided into two camps: saved, unsaved. This relates whether or not a
person receives forgiveness from Jesus Christ for their sin ... or not.
 
When a person is born:
 
You are ALREADY dead in sin. You ONLY know what your flesh feeds you. We
are more than our flesh. Eternal life is life of the spirit, not the flesh,
and because of sin we have ALREADY been judged and are no longer alive in
our spirit.
 
Below is the life cycle of each of us, for we are more than this flesh, and
we continue on after we leave this world:
 
Eventual Believer Non-believer
--------------------------------------- ---------------------------------
FLESH SPIRIT == FLESH SPIRIT
===== ====== == ===== ======
| (dead) == | (dead)
| || == | ||
(born) | (dead) == (born) | (dead)
|| | || == || | ||
(grow) | (dead) == (grow) | (dead)
|| | || == || | ||
+-------------------------------------+ == || | (dead)
| (accepts Christ as (born again) | == || | ||
| Savior and Lord) (alive) | == || | (dead)
| || || | == || | ||
| (live, work) (alive) | == (live, work) | (dead)
| || || | == || | ||
| (age) (alive) | == (age) | (dead)
| || || | == || | ||
| (die) (alive) | == (die) | (dead)
| || | == || | ||
| Note: Once the (rewards) | == (sleep) | (dead)
| believer accepts || | == | ||
| forgiveness of (alive with | == | (judgment)
| their sin, then God forever)| == | ||
| the flesh and || | == | (cast into
| the spirit are (Heaven) | == | Hell forever)
| one in the new || | == | ||
| believer's life. (alive) | == | (torment)
| || | == | ||
| God's Holy Spirit (joy) | == | (death)
| guides us in our || | == | ||
| flesh / natural (alive) | == | (torment)
| life, as a down || | == | ||
| payment of the (peace) | == | (death)
| full live we || | == | ||
| receive in His (alive) | == | (torment)
| Kingdom in all || | == | ||
| of eternity. (happiness) | == | (death)
| || | == | ||
| (alive) | == | (torment)
| || | == | ||
| (learning) | == | (death)
| || | == | ||
| (alive) | == | (torment)
| || | == | ||
| (growing) | == | (death)
| || | == | ||
| (alive) | == | (torment)
| || | == | ||
+-------------------------------------+ ---------------------------------

And it goes on. For those alive with Christ, exploring the universe,
learning ever more about His Kingdom. How much is there to know? How
deep is an infinite God? How vast is the Kingdom He's created here for
us to explore?
 
I would save people from that quick end of being cast into Hell and being
tormented forever, by teaching them to come to Jesus Christ and ask for
forgiveness for their sin.
 
You do have sin.
You do need forgiveness.
Jesus is ready to forgive you.
Ask Him to forgive you and make your spirit alive forever.
 
For those who are only born once (of the flesh), you will die twice
(once of the flesh, once of the spirit). But for those who are born
twice (once of the flesh, once of the spirit), you will only die once.
 
Both will receive an eternal body after we leave this world. But the
one who dies with their sin remaining charged to them will be cast into
Hell, because they never came to accept the truth, never came to accept
that Jesus Christ is truth, that He cleanses us from all unrighteousness.
 
Your eternal fate depends ENTIRELY upon what YOU do with Jesus Christ.
Ignore Him or accept His free offer of salvation ... the choice is yours.
 
--
Rick C. Hodgin
rick.c.hodgin.rick.c.hodgin@gmail.com: May 01 11:31AM -0700

This post describes the life timeline of each person on Earth. People are
divided into two camps: saved, unsaved. This relates whether or not a
person receives forgiveness from Jesus Christ for their sin ... or not.
 
When a person is born:
 
You are ALREADY dead in sin. You ONLY know what your flesh feeds you. We
are more than our flesh. Eternal life is life of the spirit, not the flesh,
and because of sin we have ALREADY been judged and are no longer alive in
our spirit.
 
Below is the life cycle of each of us, for we are more than this flesh, and
we continue on after we leave this world:
 
Eventual Believer Non-believer
--------------------------------------- ---------------------------------
FLESH SPIRIT == FLESH SPIRIT
===== ====== == ===== ======
| (dead) == | (dead)
| || == | ||
(born) | (dead) == (born) | (dead)
|| | || == || | ||
(grow) | (dead) == (grow) | (dead)
|| | || == || | ||
+-------------------------------------+ == || | (dead)
| (accepts Christ as (born again) | == || | ||
| Savior and Lord) (alive) | == || | (dead)
| || || | == || | ||
| (live, work) (alive) | == (live, work) | (dead)
| || || | == || | ||
| (age) (alive) | == (age) | (dead)
| || || | == || | ||
| (die) (alive) | == (die) | (dead)
| || | == || | ||
| Note: Once the (rewards) | == (sleep) | (dead)
| believer accepts || | == | ||
| forgiveness of (alive with | == | (judgment)
| their sin, then God forever)| == | ||
| the flesh and || | == | (cast into
| the spirit are (Heaven) | == | Hell forever)
| one in the new || | == | ||
| believer's life. (alive) | == | (torment)
| || | == | ||
| God's Holy Spirit (joy) | == | (death)
| guides us in our || | == | ||
| flesh / natural (alive) | == | (torment)
| life, as a down || | == | ||
| payment of the (peace) | == | (death)
| full live we || | == | ||
| receive in His (alive) | == | (torment)
| Kingdom in all || | == | ||
| of eternity. (happiness) | == | (death)
| || | == | ||
| (alive) | == | (torment)
| || | == | ||
| (learning) | == | (death)
| || | == | ||
| (alive) | == | (torment)
| || | == | ||
| (growing) | == | (death)
| || | == | ||
| (alive) | == | (torment)
| || | == | ||
+-------------------------------------+ ---------------------------------

And it goes on. For those alive with Christ, exploring the universe,
learning ever more about His Kingdom. How much is there to know? How
deep is an infinite God? How vast is the Kingdom He's created here for
us to explore?
 
I would save people from that quick end of being cast into Hell and being
tormented forever, by teaching them to come to Jesus Christ and ask for
forgiveness for their sin.
 
You do have sin.
You do need forgiveness.
Jesus is ready to forgive you.
Ask Him to forgive you and make your spirit alive forever.
 
For those who are only born once (of the flesh), you will die twice
(once of the flesh, once of the spirit). But for those who are born
twice (once of the flesh, once of the spirit), you will only die once.
 
Both will receive an eternal body after we leave this world. But the
one who dies with their sin remaining charged to them will be cast into
Hell, because they never came to accept the truth, never came to accept
that Jesus Christ is truth, that He cleanses us from all unrighteousness.
 
Your eternal fate depends ENTIRELY upon what YOU do with Jesus Christ.
Ignore Him or accept His free offer of salvation ... the choice is yours.
 
--
Rick C. Hodgin
boltar@cylonHQ.com: May 01 08:49AM

On 30 Apr 2018 22:15:08 GMT
> call "brittle"). But the program will /reliably/ report,
> whether under the implementation used »0.1 + 0.2« is »0.3«.
> So, »==« does exactly what it's job is.
 
I can't help thinking that perhaps the compiler and/or FPU designers should
make an effort to make this work. After all, if a computer can't reliably
compare numbers then that rather goes against its whole raison d'etre. Yes
I know there are ways around it but frankly one shouldn't have to bugger about
doing conversions just to carry out such a basic operation.
Paavo Helde <myfirstname@osa.pri.ee>: May 01 01:57PM +0300

>> So, »==« does exactly what it's job is.
 
> I can't help thinking that perhaps the compiler and/or FPU designers should
> make an effort to make this work.
 
It is simple to make 0.1+0.2 to "work", one just needs to design and
build base 10 floating-point hardware, instead of base 2. It would
probably be several times more expensive than the current hardware.
Considering that one would not get rid of round-off errors on this
hardware either, it seems like a massive overkill which does not
actually solve anything.
 
There is nothing inherently valuable in decimal representation of
numbers. The idea to build hardware which would guarantee limited exact
arithmetics in the case determined by the number of our fingers seems a
bit preposterous to me.
Robert Wessel <robertwessel2@yahoo.com>: May 01 10:50AM -0500

On Tue, 01 May 2018 13:57:09 +0300, Paavo Helde
>Considering that one would not get rid of round-off errors on this
>hardware either, it seems like a massive overkill which does not
>actually solve anything.
 
 
It seems unlikely that adding DFP would be a huge cost driver. IBM
and Fujitsu have added DFP to Z, POWER and SPARC, with minimal impact
of core size - a few percent at worst. I'm more familiar with IBM's
hardware, and they seem to have done several iterations where single
FPUs handle both IEEE binary and decimal FP, and on some versions of
Z, HFP as well.
 
So if Intel saw a purpose, I'm sure they could add it. And I suspect
it would be a lot less costly than something like TSX or AVX-512.
 
 
>numbers. The idea to build hardware which would guarantee limited exact
>arithmetics in the case determined by the number of our fingers seems a
>bit preposterous to me.
 
 
I mostly agree. There *are* places where the decimal nature of some
calculations need to be considered, notably those involving currency,
but those can be done in binary, provided reasonable support exists
for conversion between decimal formats and binary, and for decimal
scaling. And currency calculations are usually served better by fixed
point formats anyway.
boltar@cylonHQ.com: May 01 03:57PM

On Tue, 01 May 2018 13:57:09 +0300
>> make an effort to make this work.
 
>It is simple to make 0.1+0.2 to "work", one just needs to design and
>build base 10 floating-point hardware, instead of base 2. It would
 
Why would you even need to do that? I don't know much about the maths behind
floating point operations, but if the floating point was simply stored as 2
integers - 1 for the integer part, 1 for the fractional part - then any
floating point value up to the limits of each integer could be stored exactly
rather than the current system of using a mantissa and exponent.
Paavo Helde <myfirstname@osa.pri.ee>: May 01 08:12PM +0300

> integers - 1 for the integer part, 1 for the fractional part - then any
> floating point value up to the limits of each integer could be stored exactly
> rather than the current system of using a mantissa and exponent.
 
It could, but then the dynamic range of the values would be limited to
e.g. from 1/2^32 to 2^32 (i.e. 2E-10 .. 4E+9), which is pretty narrow
compared to current double range 2E-308 .. 2E+308 (assuming 2x32-bit
integers here for a fair comparison with a 64-bit double). A lot of
actually needed calculations involve things like gigahertzes or
picometers which would not be easily representable/convertible in that
system.
 
OTOH, there are rational number libraries out there doing such things.
Hardware support would be probably faster, but I believe no one has
bothered to implement it. Things like pi or sin(1) would still be
represented inexactly, as well as seemingly innocent things like
100000/100001 + 100001/100000.
 
There is also
"https://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic" but this
is ultimately software-based as one cannot (does not want to?) make
CPU/FPU registers very large.
jameskuyper@alumni.caltech.edu: May 01 10:19AM -0700


> I can't help thinking that perhaps the compiler and/or FPU designers should
> make an effort to make this work. After all, if a computer can't reliably
> compare numbers then that rather goes against its whole raison d'etre.
 
Unreliable comparisons are the subject of this thread, but a conforming
implementation of C++ is not allowed to implement comparisons
unreliably. The key problem isn't unreliable comparisons, but the fact
that any type with a finite size can only represent exactly a finite set
of values. And between any two different consecutive representable
values lie a continuous infinity of values that could be the
mathematically correct result of calculations involving representable
values. How would you have them deal with that fact, so as to avoid this
problem?
IEEE 754 requires that most operations produce the same result as if
calculated with infinite precision, and then rounded to the nearest
representable value. I don't see how you could request more than that,
and even with that specification you still have comparisons such as
these failing: the representable number that is closest to 0.1, when
added to the representable number that is closest to 0.2, has a
mathematically exact result that is not necessarily closest to the same
representable value that 0.3 is closest to.
By using fixed-point math or decimal floating point, you can make
certain values representable, with the result that particular
comparisons become exact. However, all you're doing by that approach is
rearranging the deck chairs on the Titanic. There will always be
infinitely times as many unrepresentable values as representable ones,
and that fact will always result in some comparisons failing that
should, mathematically, have been true (and vice versa).
ram@zedat.fu-berlin.de (Stefan Ram): Apr 30 10:15PM

>The fact that comparing floating point values with == is inherently
>brittle is a *fact*, and there is nothing superstitious with it.
 
The following program will print whether under the
implementation used »0.1 + 0.2« is equal to »0.3«.
 
main.cpp
 
#include <iostream>
#include <ostream>
 
int main()
{ ::std::cout <<( 0.1 + 0.2 == 0.3 )<< '\n'; }
 
transcript
 
0
 
The value representation of floating-point types is
implementation-defined in C++, so the behavior of the above
program might be implementation-defined (if this is what you
call "brittle"). But the program will /reliably/ report,
whether under the implementation used »0.1 + 0.2« is »0.3«.
So, »==« does exactly what it's job is.
Real Troll <real.troll@trolls.com>: May 01 12:40PM -0400

On 01/05/2018 17:19, Daniel wrote:
> #include <B.hpp>
 
> Comments?
 
> Daniel
 
Solution 3:
Create a 3rd header files (call it C.hpp) with just these two entries:
 
 
#include <A.hpp>
#include <B.hpp>
 
Now you need to include only the C.hpp in your main.cpp.
 
 
Daniel <danielaparker@gmail.com>: May 01 09:19AM -0700

Consider the header file A.hpp, which contains a definition of A,
 
class A
{
};
 
Now suppose we introduce a new header file B.hpp, which contains a definition of B that uses A,
 
#include <A.hpp>
 
struct B
{
void f()
{
A a;
}
};
 
Now, suppose it's desirable for our users that including A.hpp also brings
in B, and we particularly want to keep the name A for that header file.
 
Solution 1. include B.hpp at the bottom of A.hpp (but I've never actually seen anyone do this, include header files at the bottom.) Is this bad?
 
Solution 2 (seems to be the boost approach)
 
Move the definition of class A to a separate file, boost likes detail/A.hpp,
and rewrite A.hpp as
 
#include <detail/A.hpp>
#include <B.hpp>
 
Comments?
 
Daniel
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: