Wednesday, October 30, 2013

comp.lang.c++ - 26 new messages in 6 topics - digest

comp.lang.c++
http://groups.google.com/group/comp.lang.c++?hl=en

comp.lang.c++@googlegroups.com

Today's topics:

* And the mythical man month rears its ugly head again - 9 messages, 5 authors
http://groups.google.com/group/comp.lang.c++/t/14de696de81237ff?hl=en
* static function in named namespace - 4 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/97c149400be76b3b?hl=en
* Can straight line est fit with error measure be made in single pass? - 1
messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/9d315080851a97ca?hl=en
* String class and the use of char*/const char* - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/deff4cb6c8ab6f38?hl=en
* Request for build feedback - 10 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/dc0fd05b60e1fac5?hl=en
* Integer arithmetic when overflow exists - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/817dc36a142b4ac5?hl=en

==============================================================================
TOPIC: And the mythical man month rears its ugly head again
http://groups.google.com/group/comp.lang.c++/t/14de696de81237ff?hl=en
==============================================================================

== 1 of 9 ==
Date: Fri, Oct 25 2013 5:47 pm
From: Geoff


On Fri, 25 Oct 2013 17:13:31 +0200, Bo Persson <bop@gmb.dk> wrote:

>
>The problem here is that he probably voted for the minority that
>believes health care for the population is a waste of money and can't
>accept that the administration proposing that actually was re-elected.
>
>Democracy is only good when your own side wins?

I voted for Obama because McCain proved himself insane by choosing
Palin as a running mate. I prefer my presidents crafty and sane. I
also would be in favor of single-payer but Europe and Canada have
demonstrated that you can't have single-payer without rationing and
lack of availability.

I had an ER experience in 2009. Four days in hospital. Net result, a
bill for $80,000+ from the hospital. Net paid by private insurance
carrier by contract $17,700. Net co-pay to me $890. I don't know where
the rest of it disappeared into. Never heard another peep from anyone.

In 2002 I was in England and came down with otitus. This is a problem
when your a yank and your not on the national healthcare plan, or is
it? Have the local guy take you to the clinic and explain your
situation, pay twenty pounds to the doctor for the exam and
prescription, stop at the chemist on the way home, another 17 pounds
for medicine and were all back at the pub for bangers and mash.

Here's what the future holds for America: Fewer doctors, fewer
hospitals, lower quality care, longer wait times for surgeries,
problems with approval for treatments, higher costs all around.




== 2 of 9 ==
Date: Fri, Oct 25 2013 5:49 pm
From: Geoff


On Fri, 25 Oct 2013 15:55:04 -0700 (PDT), woodbrian77@gmail.com wrote:

>One reason I'm opposed to Obamacare is people should be
>free to associate with those they choose as far as
>health care.

The fundamental problem with national health care is the coercion. You
will be fined or harassed until you join the lemmings.




== 3 of 9 ==
Date: Fri, Oct 25 2013 6:24 pm
From: Ian Collins


Geoff wrote:
>
> Here's what the future holds for America: Fewer doctors, fewer
> hospitals, lower quality care, longer wait times for surgeries,
> problems with approval for treatments, higher costs all around.

Maybe they'll migrate down here.

Those of us in civilised parts of the world where universal healthcare
is a given always enjoy a hearty chuckle at our American friends
getting to a lather over what we take for granted. Here universal
healthcare isn't an issue, it just is!

Now back to some C++...

--
Ian Collins




== 4 of 9 ==
Date: Fri, Oct 25 2013 7:13 pm
From: woodbrian77@gmail.com


On Friday, October 25, 2013 7:33:02 PM UTC-5, Geoff wrote:

> In some ways a parliamentary process is superior to the process we
> have in the states. Only a maximum of 1/3 of the house can be turned
> out in a single election so for a complete turn-over it takes 6 years.

Every seat in the House is up for election every 2 years.




== 5 of 9 ==
Date: Sat, Oct 26 2013 12:35 am
From: Bo Persson


Geoff skrev 2013-10-26 02:49:
> On Fri, 25 Oct 2013 15:55:04 -0700 (PDT), woodbrian77@gmail.com wrote:
>
>> One reason I'm opposed to Obamacare is people should be
>> free to associate with those they choose as far as
>> health care.
>
> The fundamental problem with national health care is the coercion. You
> will be fined or harassed until you join the lemmings.
>

Yeah, that's the point - everyone is covered.

The argument that some of you could get better care if others get
nothing doesn't really bite on non-Americans.


Bo Persson





== 6 of 9 ==
Date: Sat, Oct 26 2013 1:01 am
From: Geoff


On Sat, 26 Oct 2013 09:35:47 +0200, Bo Persson <bop@gmb.dk> wrote:

>Geoff skrev 2013-10-26 02:49:
>> On Fri, 25 Oct 2013 15:55:04 -0700 (PDT), woodbrian77@gmail.com wrote:
>>
>>> One reason I'm opposed to Obamacare is people should be
>>> free to associate with those they choose as far as
>>> health care.
>>
>> The fundamental problem with national health care is the coercion. You
>> will be fined or harassed until you join the lemmings.
>>
>
>Yeah, that's the point - everyone is covered.
>
>The argument that some of you could get better care if others get
>nothing doesn't really bite on non-Americans.
>
>

Actually, those others don't get "nothing". They get the same
treatment now as they would under Obamacare. No hospital refuses care
based on ability to pay. If you walk into ER and need surgery, you get
it, then and there if necessary. The hospitals make up for the lost
revenue by increasing the charges for those with insurance.

Under the new plan, those who cannot afford to pay the premiums will
be subsidized, whose who can pay more will be paying larger premiums
up front. Socialism is complete, redistribution is done by the central
government and the nanny state is in charge, like it or not.

Why should there be a requirement to "buy in" at all? Simply use the
money collected by income taxes to pay for it all.




== 7 of 9 ==
Date: Sat, Oct 26 2013 10:16 am
From: woodbrian77@gmail.com


On Saturday, October 26, 2013 2:35:47 AM UTC-5, Bo Persson wrote:
>
> Yeah, that's the point - everyone is covered.
>
> The argument that some of you could get better care if others get
> nothing doesn't really bite on non-Americans.
>

As I see it this is a little bit of Obama's record:

Number of people on food stamps is up 12 million
Record poverty
Debt to GDP ratio has increased

He has sucked in so many ways. I don't trust him
and wouldn't vote for him if he were running for
dog catcher.




== 8 of 9 ==
Date: Sat, Oct 26 2013 11:08 am
From: "brad"



"Geoff" <geoff@invalid.invalid> wrote in message
news:chsm699pl5mmh9bl9n2hqepqkqhn329mio@4ax.com...
> On Sat, 26 Oct 2013 09:35:47 +0200, Bo Persson <bop@gmb.dk> wrote:
>
>>Geoff skrev 2013-10-26 02:49:
>>> On Fri, 25 Oct 2013 15:55:04 -0700 (PDT), woodbrian77@gmail.com wrote:
>>>
>>>> One reason I'm opposed to Obamacare is people should be
>>>> free to associate with those they choose as far as
>>>> health care.
>>>
>>> The fundamental problem with national health care is the coercion. You
>>> will be fined or harassed until you join the lemmings.
>>>
>>
>>Yeah, that's the point - everyone is covered.
>>
>>The argument that some of you could get better care if others get
>>nothing doesn't really bite on non-Americans.
>>
>>
>
> Actually, those others don't get "nothing". They get the same
> treatment now as they would under Obamacare. No hospital refuses care
> based on ability to pay. If you walk into ER and need surgery, you get
> it, then and there if necessary. The hospitals make up for the lost
> revenue by increasing the charges for those with insurance.
>
> Under the new plan, those who cannot afford to pay the premiums will
> be subsidized, whose who can pay more will be paying larger premiums
> up front. Socialism is complete, redistribution is done by the central
> government and the nanny state is in charge, like it or not.
>
> Why should there be a requirement to "buy in" at all? Simply use the
> money collected by income taxes to pay for it all.

The people who are really getting screwed over by this are the young people.
The law say that the insurance rate for a 64 year old, obese, alcoholic can
be no more than three times the rate for a fit 21 year old with a healthy
life style. The number 3 was arrived at, mostly, by a bunch of guys who
went to law school but barely practiced law, not actuaries. Except for when
I was in the army I never went to a doctor even once until I was in my
fifties. Many years ago, health care was 10% of the GNP, I am sure the
proportion has grown a lot since then. Of course, much of that 10% already
came from the government in the form of Medicaid and Medicare, now the young
can, and will, supplement that source.

The young are also being screwed by the debt thing. Someday, the Chinese
are going to want actual money, not a new IOU to replace the current one.
Who is going to live through that inflationary period? Same guys.






== 9 of 9 ==
Date: Sat, Oct 26 2013 9:08 pm
From: Geoff


On Sat, 26 Oct 2013 13:08:44 -0500, "brad" <noise@comcast.net> wrote:

>
>"Geoff" <geoff@invalid.invalid> wrote in message
>news:chsm699pl5mmh9bl9n2hqepqkqhn329mio@4ax.com...
>> On Sat, 26 Oct 2013 09:35:47 +0200, Bo Persson <bop@gmb.dk> wrote:
>>
>>>Geoff skrev 2013-10-26 02:49:
>>>> On Fri, 25 Oct 2013 15:55:04 -0700 (PDT), woodbrian77@gmail.com wrote:
>>>>
>>>>> One reason I'm opposed to Obamacare is people should be
>>>>> free to associate with those they choose as far as
>>>>> health care.
>>>>
>>>> The fundamental problem with national health care is the coercion. You
>>>> will be fined or harassed until you join the lemmings.
>>>>
>>>
>>>Yeah, that's the point - everyone is covered.
>>>
>>>The argument that some of you could get better care if others get
>>>nothing doesn't really bite on non-Americans.
>>>
>>>
>>
>> Actually, those others don't get "nothing". They get the same
>> treatment now as they would under Obamacare. No hospital refuses care
>> based on ability to pay. If you walk into ER and need surgery, you get
>> it, then and there if necessary. The hospitals make up for the lost
>> revenue by increasing the charges for those with insurance.
>>
>> Under the new plan, those who cannot afford to pay the premiums will
>> be subsidized, whose who can pay more will be paying larger premiums
>> up front. Socialism is complete, redistribution is done by the central
>> government and the nanny state is in charge, like it or not.
>>
>> Why should there be a requirement to "buy in" at all? Simply use the
>> money collected by income taxes to pay for it all.
>
>The people who are really getting screwed over by this are the young people.
>The law say that the insurance rate for a 64 year old, obese, alcoholic can
>be no more than three times the rate for a fit 21 year old with a healthy
>life style. The number 3 was arrived at, mostly, by a bunch of guys who
>went to law school but barely practiced law, not actuaries. Except for when
>I was in the army I never went to a doctor even once until I was in my
>fifties. Many years ago, health care was 10% of the GNP, I am sure the
>proportion has grown a lot since then. Of course, much of that 10% already
>came from the government in the form of Medicaid and Medicare, now the young
>can, and will, supplement that source.
>
>The young are also being screwed by the debt thing. Someday, the Chinese
>are going to want actual money, not a new IOU to replace the current one.
>Who is going to live through that inflationary period? Same guys.
>

Yep, same here. In retrospect I would have used doctors more. When I
was 24 I was paying premiums for services I wasn't using. They count
on that. But I was the young buck back then, paying for the older
guys' retirements and pensions and now I have to fund my own with
401(k) and IRA money and there's no pension fund to rely on because
they liquidated or stole it all. Now I'm 59 and seeing a doctor every
two months to be sure the 6 medications I'm taking for heart disease
aren't killing my liver.

It always sucks to be young and penniless and paying someone else's
debt. Then it sucks to be old and tired and paying someone else's
debt. Then you die and they collect all your wealth and pay someone
else's debt.





==============================================================================
TOPIC: static function in named namespace
http://groups.google.com/group/comp.lang.c++/t/97c149400be76b3b?hl=en
==============================================================================

== 1 of 4 ==
Date: Sat, Oct 26 2013 5:42 am
From: Tobias Müller


Jorgen Grahn <grahn+nntp@snipabacken.se> wrote:
> On Wed, 2013-10-23, Tobias Müller wrote:
>> Jorgen Grahn <grahn+nntp@snipabacken.se> wrote:
>>
>> [...]
>>
>>> I don't have any
>>> major problems with your way, but I don't want most of my code to be
>>> indented.
>>
>> I don't indent namespaces anyway. Usually I don't have more than one
>> namespace in a file so I don't see any advantage in it.
>
> Yeah, that was something I considered doing for a while. In the end
> it boiled down to "I don't want others to have to fight their editor
> about the indentation" and "I don't want to learn how to train Emacs
> not to indent namespaces".

In my experience this is only a problem when inserting something at the
very beginning of the namespace. At least Visual Studio only considers the
local context when indenting.
Except when you autoformat the whole file of course, but I almost never do
that.

> (On the other hand I'm not consistent: Emacs wants to indent 'extern
> "C"' blocks and that's clearly crazy from a C perspective.)

You mean because of the usual #ifdef __cplusplus guards?
Conditional compilation like that makes "correct" indenting impossible
anyway.

Tobi




== 2 of 4 ==
Date: Sat, Oct 26 2013 9:00 am
From: Jorgen Grahn


On Sat, 2013-10-26, Tobias Müller wrote:
> Jorgen Grahn <grahn+nntp@snipabacken.se> wrote:
>> On Wed, 2013-10-23, Tobias Müller wrote:
>>> Jorgen Grahn <grahn+nntp@snipabacken.se> wrote:
>>>
>>> [...]
>>>
>>>> I don't have any
>>>> major problems with your way, but I don't want most of my code to be
>>>> indented.
>>>
>>> I don't indent namespaces anyway. Usually I don't have more than one
>>> namespace in a file so I don't see any advantage in it.
>>
>> Yeah, that was something I considered doing for a while. In the end
>> it boiled down to "I don't want others to have to fight their editor
>> about the indentation" and "I don't want to learn how to train Emacs
>> not to indent namespaces".
>
> In my experience this is only a problem when inserting something at the
> very beginning of the namespace. At least Visual Studio only considers the
> local context when indenting.
> Except when you autoformat the whole file of course, but I almost never do
> that.
>
>> (On the other hand I'm not consistent: Emacs wants to indent 'extern
>> "C"' blocks and that's clearly crazy from a C perspective.)
>
> You mean because of the usual #ifdef __cplusplus guards?
> Conditional compilation like that makes "correct" indenting impossible
> anyway.

I meant it's "clearly crazy" because you want to distract C users of
your header file as little as possible, so they don't petition you to
drop C++ compatibility ...

At least with Emacs, I don't think the indenting logic looks at
#ifdefs at all.

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .




== 3 of 4 ==
Date: Sun, Oct 27 2013 1:57 am
From: Rupert Swarbrick


Jorgen Grahn <grahn+nntp@snipabacken.se> writes:
> At least with Emacs, I don't think the indenting logic looks at
> #ifdefs at all.

The curly bracket in

extern "C" {

makes Emacs indent the following line. But if you manually put the first
declaration at column zero, Emacs "does what you want" for following
ones.


Rupert




== 4 of 4 ==
Date: Sun, Oct 27 2013 1:56 am
From: Rupert Swarbrick


Jorgen Grahn <grahn+nntp@snipabacken.se> writes:
> At least with Emacs, I don't think the indenting logic looks at
> #ifdefs at all.

The curly bracket in

extern "C" {

makes Emacs indent the following line. But if you manually put the first
declaration at column zero, Emacs "does what you want" for following
ones.


Rupert





==============================================================================
TOPIC: Can straight line est fit with error measure be made in single pass?
http://groups.google.com/group/comp.lang.c++/t/9d315080851a97ca?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Oct 26 2013 10:55 am
From: Richard Damon


On 10/23/13, 8:59 AM, SG wrote:
> On Saturday, October 19, 2013 3:57:36 AM UTC+2, Alf P. Steinbach wrote:
>> It would be nice if one could make do with a non-copyable forward
>> iterator for the (x,y) data points, without storing the points.
>
> Let me just mention that this extends to any linear least squares
> problem. The amount of memory you really need is just determined by
> the number of unknowns, not the number of "data points". Suppose
>
> A x = b
>
> is an overdetermined linear equation system with very few unknowns
> (and hence very hew columns in A) but many equations (rows in A).
> Then, you can, for example, compute A^T A and A^T b of
>
> A^T A x = A^T b // Gauss' normal equation system
>
> using a single loop over all rows of A and b. A^T A will be a small
> square matrix with n^2 entries where n is the number of unknowns.
> This can then be solved with a Cholesky factorization, for example.
>
> Other approaches are possible, too. If you care about numerical
> accuracy you could "accumulate" a couple of rows and periorically
> reduce the whole system to O(n^2) memory via Householder
> transformations.
>
> Cheers!
> SG
>

Note that Least Square fits are NOT overdetermined linear equations. You
do not get a "equation" for each data point when processing, but a
multidimensional optimization problem, with one dimension for each
unknown to find. This tends to be converted to a set of equations by
taking the partial derivative of the error over each coefficient to
solve for and finding the location where all the derivatives are zero.
What is helpful is that for a large class of problems, you don't need to
keep all the data points to solve the system, but can reduce the data
points to a limited number of moments, that the solution is based on.





==============================================================================
TOPIC: String class and the use of char*/const char*
http://groups.google.com/group/comp.lang.c++/t/deff4cb6c8ab6f38?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Oct 26 2013 11:31 am
From: Marcel Müller


On 23.10.13 11.17, goran.pusic@gmail.com wrote:
> Hi all,
>
> we seem to be having a style issue in the team.
>
> We have a string class that has char* and const char* conversion operators

operator const char* is mostly fine, but as soon as you implement
operator char* your code is close to death. There are hundreds of
drawbacks. Most importantly your code can easily have undefined behavior
where no compiler can give you any warnings or errors. (Believe me, I
have written some string classes so far.)

From my experience as soon as a C++ program uses char* (without const)
is is mostly buggy. For instance it is likely to have buffer overrun
vulnerabilities.

> (yes, i know we should be using std::string, please bear with me).

I, know, std::string is not always an option.

> Some people in the team prefer that, when calling code like this:
>
> retval func(..., const char* param, ...);
>
> with an instance of our string class, we use an explicit cast, e.g.

As I said, const char* is mostly safe. You only have to check for
dangling references, but no more than with that C API anyway.


> mystring s(whatever);
> func(..., (const char*)s, ...);

This cast is the worst case, since i would also cast mystring* or
whatever to (const char*). Things you usually don't want to do without a
compiler warning.

The common way is to provide a conversion function like c_str().


> Can I please have your opinion on this (good/bad/like/not like)? Insight?
> (My purpose, obviously, is to show your responses to the team).

- Remove operator char*.
- Remove char* from the C** source wherever possible.
- If you really need to adopt C APIs with char* without O(n) copies
provide a function like char* mystring::allocate(size_t length) that
ensures length+1 writeable characters until any other non-const mystring
function call for this instance while s[length] should not receive
anything but \0.


Marcel





==============================================================================
TOPIC: Request for build feedback
http://groups.google.com/group/comp.lang.c++/t/dc0fd05b60e1fac5?hl=en
==============================================================================

== 1 of 10 ==
Date: Sat, Oct 26 2013 1:54 pm
From: woodbrian77@gmail.com


On Thursday, July 25, 2013 9:49:22 PM UTC-5, woodb...@gmail.com wrote:
> On Thursday, July 25, 2013 6:40:12 PM UTC-5, woodb...@gmail.com wrote:
> >
>
> > The file to download is 21,059 bytes at this time so
> > downloading it shouldn't take long. On my Linux system
> > the library and two programs build in 9 seconds.
>
> I guess it's more like 7 seconds here.
>

I'm happy to report that the software builds consistently
now in under 6 seconds. This is on the same hardware and
with the same compiler as I used in July. I've made a number
of changes to the software since July that have improved the
build time.

http://webEbenezer.net/build_integration.html


I beleive the software is well written, but there is
probably room for some improvement.




== 2 of 10 ==
Date: Sat, Oct 26 2013 2:26 pm
From: Leigh Johnston


On 26/10/2013 21:54, woodbrian77@gmail.com wrote:
> On Thursday, July 25, 2013 9:49:22 PM UTC-5, woodb...@gmail.com wrote:
>> On Thursday, July 25, 2013 6:40:12 PM UTC-5, woodb...@gmail.com wrote:
>>>
>>
>>> The file to download is 21,059 bytes at this time so
>>> downloading it shouldn't take long. On my Linux system
>>> the library and two programs build in 9 seconds.
>>
>> I guess it's more like 7 seconds here.
>>
>
> I'm happy to report that the software builds consistently
> now in under 6 seconds. This is on the same hardware and
> with the same compiler as I used in July. I've made a number
> of changes to the software since July that have improved the
> build time.
>
> http://webEbenezer.net/build_integration.html
>
>
> I beleive the software is well written, but there is
> probably room for some improvement.

Hello Mr Homophobic Bigot. Where is your usual god bothering .sig?

Haven't you noticed that nobody on Usenet cares about your fucking
library yet? Best your posts on it do is start stupid discussions about
misuse of namespaces.

Lose the bigotry and go make something useful.

/Leigh





== 3 of 10 ==
Date: Sat, Oct 26 2013 3:21 pm
From: woodbrian77@gmail.com


On Saturday, October 26, 2013 4:26:14 PM UTC-5, Leigh Johnston wrote:


Please don't swear here.

I gave this thread an update in part because there are
new people rolling through here from time to time.

If you have some technical criticism of the software I'd
be happy to hear it.




== 4 of 10 ==
Date: Sun, Oct 27 2013 6:23 am
From: Leigh Johnston


On 26/10/2013 23:21, woodbrian77@gmail.com wrote:
> On Saturday, October 26, 2013 4:26:14 PM UTC-5, Leigh Johnston wrote:
>
>
> Please don't swear here.

Do you seriously believe that asking nicely will stop people swearing in
here you cunt?

>
> I gave this thread an update in part because there are
> new people rolling through here from time to time.

But your posts about it are usually random and inane like "my
compilation time changed by a second". Usenet is not your own personal
diary.

>
> If you have some technical criticism of the software I'd
> be happy to hear it.

Given your posts on it it seems like it is not a serious piece of
software from a not so serious company run by a misogynist, homophobic
bigoted god bothering lunatic.

/Leigh





== 5 of 10 ==
Date: Sun, Oct 27 2013 9:42 am
From: woodbrian77@gmail.com


On Sunday, October 27, 2013 8:23:27 AM UTC-5, Leigh Johnston wrote:
> On 26/10/2013 23:21, woodbrian77@gmail.com wrote:
>
> > On Saturday, October 26, 2013 4:26:14 PM UTC-5, Leigh Johnston wrote:
>
> >
>
> >
>
> > Please don't swear here.
>
>
>
> Do you seriously believe that asking nicely will stop people swearing

Yes, and please don't use sexual slurs here.

>
> >
>
> > I gave this thread an update in part because there are
> > new people rolling through here from time to time.
>
> But your posts about it are usually random and inane like "my
> compilation time changed by a second".

The software was good in July and is better now.

> Usenet is not your own personal
> diary.
>

Remember this part of Psalm 23.

5 You prepare a table before me in the presence of my enemies;
You have anointed my head with oil;
My cup overflows.
6 Surely goodness and lovingkindness will follow me all
the days of my life,
And I will dwell in the house of the L-rd forever.


And then bring in "One man's trash is another man's treasure."
My software may be trash to you, but to poverty stricken
people from India, China, Russia, Nepal. Egypt, Greece, Spain,
Mexico etc., it's a lifesaver. Why? Because it's free and
of increasingly high quality. G-d's will is to help His people
and they are all over the globe.




== 6 of 10 ==
Date: Sun, Oct 27 2013 9:49 am
From: Leigh Johnston


On 27/10/2013 16:42, woodbrian77@gmail.com wrote:
> On Sunday, October 27, 2013 8:23:27 AM UTC-5, Leigh Johnston wrote:
>> On 26/10/2013 23:21, woodbrian77@gmail.com wrote:
>>
>>> On Saturday, October 26, 2013 4:26:14 PM UTC-5, Leigh Johnston wrote:
>>
>>>
>>
>>>
>>
>>> Please don't swear here.
>>
>>
>>
>> Do you seriously believe that asking nicely will stop people swearing
>
> Yes, and please don't use sexual slurs here.
>
>>
>>>
>>
>>> I gave this thread an update in part because there are
>>> new people rolling through here from time to time.
>>
>> But your posts about it are usually random and inane like "my
>> compilation time changed by a second".
>
> The software was good in July and is better now.
>
>> Usenet is not your own personal
>> diary.
>>
>
> Remember this part of Psalm 23.
>
> 5 You prepare a table before me in the presence of my enemies;
> You have anointed my head with oil;
> My cup overflows.
> 6 Surely goodness and lovingkindness will follow me all
> the days of my life,
> And I will dwell in the house of the L-rd forever.
>
>
> And then bring in "One man's trash is another man's treasure."
> My software may be trash to you, but to poverty stricken
> people from India, China, Russia, Nepal. Egypt, Greece, Spain,
> Mexico etc., it's a lifesaver. Why? Because it's free and
> of increasingly high quality. G-d's will is to help His people
> and they are all over the globe.

You are fucking deluded mate.






== 7 of 10 ==
Date: Sun, Oct 27 2013 10:04 am
From: woodbrian77@gmail.com


On Sunday, October 27, 2013 11:49:53 AM UTC-5, Leigh Johnston wrote:


Too much swearing, Leigh.




== 8 of 10 ==
Date: Sun, Oct 27 2013 10:25 am
From: Leigh Johnston


On 27/10/2013 17:04, woodbrian77@gmail.com wrote:
> On Sunday, October 27, 2013 11:49:53 AM UTC-5, Leigh Johnston wrote:
>
>
> Too much swearing, Leigh.

You think I give a fuck if some god bothering bigot doesn't like swearing?

Again: you are fucking deluded mate.





== 9 of 10 ==
Date: Sun, Oct 27 2013 10:35 am
From: Öö Tiib


On Sunday, 27 October 2013 19:04:51 UTC+2, woodb...@gmail.com wrote:
>
> Too much swearing, Leigh.

Leigh has likely nothing to do and feels alone and so he specially
tries to insult you and to swear and get some reaction ... some
feed back ... anything. He does not believe that most things are
possible to get just by asking nicely from others.




== 10 of 10 ==
Date: Sun, Oct 27 2013 11:41 am
From: woodbrian77@gmail.com


On Sunday, October 27, 2013 12:35:44 PM UTC-5, Öö Tiib wrote:
>
> Leigh has likely nothing to do and feels alone and so he specially
> tries to insult you and to swear and get some reaction ... some
> feed back ... anything. He does not believe that most things are
> possible to get just by asking nicely from others.

That's OK. I have only gotten one response to my posts
where the person took me up on it and downloaded and
built it. So it probably looks like it isn't very
successful. However scores of people downloaded it so
that's a little better.

The asking nicely according to a Bible story is
sometimes being persistent until someone says,
"I'm tired of them asking so will help them." :)

If I didn't believe I have a portability advantage
over competitors because of my approach/architecture,
I probably wouldn't be so bold. My library, front
tier, and the generated code are the parts that
have to be portable. The middle tier has to be
somewhat portable, but not as much as the front tier.
The back tier doesn't have to be very portable.
The back tier is bigger than the middle tier and the
middle tier is bigger than the front tier. The front
tier is less than 100 lines (not counting generated
code) so it's expected to be easy to port to other
platforms.





==============================================================================
TOPIC: Integer arithmetic when overflow exists
http://groups.google.com/group/comp.lang.c++/t/817dc36a142b4ac5?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, Oct 27 2013 7:58 am
From: Rosario1903


On Mon, 14 Oct 2013 14:28:37 -0500, Paavo Helde wrote:

>So far, it seems that the strongest point for putting the wrap-over into
>the standard is that otherwise a bunch of x86 and other assembler
>programmers might have some misconceptions about C++.

it is not wrapp aroudn to put in the standard is overflwo flag

>Why should we care
>so much about assembler programmers?

yes why care c++s? :)
....
>No problem, I think gcc won't optimize in debug mode and will catch my UB
>in the debug mode (i am regularly running the tests in debug mode, in
>addition to the automatic release mode testing).
....
>All tests are run after each commit, in the continous integration builds.
>No problem here, other than that we don't yet have 100% code coverage in
>tests. So I will probably switch off this flag in the stable branch
>(actually delivered to customers) in order to avoid false positives at
>customer site.

in assembly, if it would be possible some overflow, i would detect
it...
i don't know how big programmers do it etc

>Cheers
>Paavo




==============================================================================

You received this message because you are subscribed to the Google Groups "comp.lang.c++"
group.

To post to this group, visit http://groups.google.com/group/comp.lang.c++?hl=en

To unsubscribe from this group, send email to comp.lang.c+++unsubscribe@googlegroups.com

To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.c++/subscribe?hl=en

To report abuse, send email explaining the problem to abuse@googlegroups.com

==============================================================================
Google Groups: http://groups.google.com/?hl=en

comp.lang.c++ - 26 new messages in 7 topics - digest

comp.lang.c++
http://groups.google.com/group/comp.lang.c++?hl=en

comp.lang.c++@googlegroups.com

Today's topics:

* A function returning an array - 3 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/416a46975f0a408f?hl=en
* And the mythical man month rears its ugly head again - 11 messages, 5
authors
http://groups.google.com/group/comp.lang.c++/t/14de696de81237ff?hl=en
* static function in named namespace - 4 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/97c149400be76b3b?hl=en
* Can straight line est fit with error measure be made in single pass? - 1
messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/9d315080851a97ca?hl=en
* String class and the use of char*/const char* - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/deff4cb6c8ab6f38?hl=en
* Request for build feedback - 5 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/dc0fd05b60e1fac5?hl=en
* Integer arithmetic when overflow exists - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/817dc36a142b4ac5?hl=en

==============================================================================
TOPIC: A function returning an array
http://groups.google.com/group/comp.lang.c++/t/416a46975f0a408f?hl=en
==============================================================================

== 1 of 3 ==
Date: Fri, Oct 25 2013 1:48 pm
From: Jorgen Grahn


On Wed, 2013-10-23, axcytz@gmail.com wrote:
...
> Thanks for your help firstly. What I tried is:
>
> Function(int myArray[], int UpdateArray[])
> {
> for(int t=0; t < NumElement; t++)
> {
> UpdateArray[t] = myArray[t];
> }
>
> swap(UpdateArray[0], UpdateArray[1]);
>
> return UpdateArray;
> }

What you're doing here would, in C++, be done using iterators:

template<class It>
void Function(It src, size_t n, It dest)
{
std::copy(src, src+n, dest);
assert(n>1);
std::swap(*dest, *dest+1);
}

But that's rather far away from the concept of "returning an array".
You're not returning anything; you are copying. Have you been working
in Java a lot?

If you want to return an object, see earlier suggestions.

> Something like this. Is the syntax correct?

Don't you have a C++ compiler? It's better at catching syntax errors
than we are. It's part of its job.

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .




== 2 of 3 ==
Date: Fri, Oct 25 2013 2:30 pm
From: Jorgen Grahn


On Fri, 2013-10-25, Jorgen Grahn wrote:
...
> What you're doing here would, in C++, be done using iterators:
>
> template<class It>
> void Function(It src, size_t n, It dest)
> {
> std::copy(src, src+n, dest);
> assert(n>1);
> std::swap(*dest, *dest+1);
> }

I suppose that should be *(dest+1); it was just an untested sketch.

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .




== 3 of 3 ==
Date: Fri, Oct 25 2013 3:21 pm
From: Ian Collins


James Kanze wrote:
> On Wednesday, 23 October 2013 05:15:45 UTC+1, Ian Collins wrote:
>> axcytz@gmail.com wrote:
>> Please clean up the mess that awful google interface makes of your quotes!
>>> Thanks for your help firstly. What I tried is:
>
>>> Function(int myArray[], int UpdateArray[])
>>> {
>>> for(int t=0; t < NumElement; t++)
>>> {
>>> UpdateArray[t] = myArray[t];
>>> }
>>> swap(UpdateArray[0], UpdateArray[1]);
>>> return UpdateArray;
>>> }
>
>>> Something like this. Is the syntax correct? Can I just say
>>> return UpdateArray?
>
>> No, you can't return an array.
>
> But UpdateArray isn't an array.

Good spot! On the ball as always.

--
Ian Collins





==============================================================================
TOPIC: And the mythical man month rears its ugly head again
http://groups.google.com/group/comp.lang.c++/t/14de696de81237ff?hl=en
==============================================================================

== 1 of 11 ==
Date: Fri, Oct 25 2013 3:55 pm
From: woodbrian77@gmail.com


On Friday, October 25, 2013 10:13:31 AM UTC-5, Bo Persson wrote:
>
> The problem here is that he probably voted for the minority that
> believes health care for the population is a waste of money and can't
> accept that the administration proposing that actually was re-elected.

One reason I'm opposed to Obamacare is people should be
free to associate with those they choose as far as
health care. That may be the only way to get people
to take responsibility for themselves. In other words,
if you smoke, use marijuana or other illegal drugs,
are obese, ... sorry, but I don't want to join you
in a health care pool. A pool of responsible people
can show others that it's possible to get reasonable
prices on health care, but you have to be accountable.

The Republican majority in the House was also re-elected.





== 2 of 11 ==
Date: Fri, Oct 25 2013 5:33 pm
From: Geoff


On Fri, 25 Oct 2013 21:12:58 +0200, David Brown
<david.brown@removethis.hesbynett.no> wrote:

>On 25/10/13 15:23, Geoff wrote:
>> On Fri, 25 Oct 2013 09:05:23 +0200, David Brown
>> <david@westcontrol.removethisbit.com> wrote:
>>
>>> Wait a minute, you /do/ live in a democracy.
>>
>> No, I don't. It's a representative republic, there's a difference.
>>
>> The Republic of the United States of America was renamed "democracy"
>> during the Roosevelt administration.
>>
>> The problem at the moment is that the idiots who vote are appointing
>> the idiots who desire wealth and power and those idiots are creating
>> 10,000 page laws that they don't read and can't understand before they
>> vote them into law.
>>
>
>I actually know all this - my post was exaggerated. The biggest problem
>with letting (almost) anybody vote about politics is that almost nobody
>is qualified to make good judgements about politics (whether this means
>a representative democracy where voters must pick suitable politicians,
>or a direct democracy where voters make the political decisions themselves).
>
That voters are unqualified to make those decisions, we agree
completely. Exacerbated by the fact that politicians make promises
they have no intention of keeping, just to get those unqualified
votes.

>The general point remains, however - the politics and government in the
>USA is strongly influenced by the voters, and the citizens have a
>responsibility for the government. If enough people feel strongly
>enough, they should be able to make changes.
>
The problem begins when Congress feels they must actually do something
like write bills and pass them. Americans like gridlock. When the
executive and legislative branches are of opposite parties, everything
is fine. If congress runs rampant, the president can veto. It's only
when we elected Obama and had a Democrat-led Senate that we ran into
problems and the ACA was passed. Clinton couldn't get it passed while
Republicans led during his terms and Reid-Pelosi couldn't get it past
Bush's veto.

>I find it ironic that the people (in the western world) who seem to
>complain most about their government, especially the federal government,
>are Americans - yet these are the same people who are most convinced
>that they have the best and most democratic political system.
>

Americans have been complaining about their government since it was
founded, it's part of the culture. Go read "John Adams" by David
McCullough for some insights. Every one of the founders could find
something wrong with the way the others ran their presidencies. About
the only president in history who was universally liked was Washington
and he achieved that by serving his two terms and retiring from public
life.

>In Europe, most people think their governments do a reasonable job most
>of the time. When they think they are doing too badly, they vote in
>someone else at the next election and the politics change (not
>everything, and not overnight, but things do change).

In some ways a parliamentary process is superior to the process we
have in the states. Only a maximum of 1/3 of the house can be turned
out in a single election so for a complete turn-over it takes 6 years.
Senators are even harder to get rid of, they prefer to die in office
or go until the bitter end like Ted Kennedy. The problem is when the
voters seem to think having these fossils in office is a good thing.




== 3 of 11 ==
Date: Fri, Oct 25 2013 5:47 pm
From: Geoff


On Fri, 25 Oct 2013 17:13:31 +0200, Bo Persson <bop@gmb.dk> wrote:

>
>The problem here is that he probably voted for the minority that
>believes health care for the population is a waste of money and can't
>accept that the administration proposing that actually was re-elected.
>
>Democracy is only good when your own side wins?

I voted for Obama because McCain proved himself insane by choosing
Palin as a running mate. I prefer my presidents crafty and sane. I
also would be in favor of single-payer but Europe and Canada have
demonstrated that you can't have single-payer without rationing and
lack of availability.

I had an ER experience in 2009. Four days in hospital. Net result, a
bill for $80,000+ from the hospital. Net paid by private insurance
carrier by contract $17,700. Net co-pay to me $890. I don't know where
the rest of it disappeared into. Never heard another peep from anyone.

In 2002 I was in England and came down with otitus. This is a problem
when your a yank and your not on the national healthcare plan, or is
it? Have the local guy take you to the clinic and explain your
situation, pay twenty pounds to the doctor for the exam and
prescription, stop at the chemist on the way home, another 17 pounds
for medicine and were all back at the pub for bangers and mash.

Here's what the future holds for America: Fewer doctors, fewer
hospitals, lower quality care, longer wait times for surgeries,
problems with approval for treatments, higher costs all around.




== 4 of 11 ==
Date: Fri, Oct 25 2013 5:49 pm
From: Geoff


On Fri, 25 Oct 2013 15:55:04 -0700 (PDT), woodbrian77@gmail.com wrote:

>One reason I'm opposed to Obamacare is people should be
>free to associate with those they choose as far as
>health care.

The fundamental problem with national health care is the coercion. You
will be fined or harassed until you join the lemmings.




== 5 of 11 ==
Date: Fri, Oct 25 2013 6:24 pm
From: Ian Collins


Geoff wrote:
>
> Here's what the future holds for America: Fewer doctors, fewer
> hospitals, lower quality care, longer wait times for surgeries,
> problems with approval for treatments, higher costs all around.

Maybe they'll migrate down here.

Those of us in civilised parts of the world where universal healthcare
is a given always enjoy a hearty chuckle at our American friends
getting to a lather over what we take for granted. Here universal
healthcare isn't an issue, it just is!

Now back to some C++...

--
Ian Collins




== 6 of 11 ==
Date: Fri, Oct 25 2013 7:13 pm
From: woodbrian77@gmail.com


On Friday, October 25, 2013 7:33:02 PM UTC-5, Geoff wrote:

> In some ways a parliamentary process is superior to the process we
> have in the states. Only a maximum of 1/3 of the house can be turned
> out in a single election so for a complete turn-over it takes 6 years.

Every seat in the House is up for election every 2 years.




== 7 of 11 ==
Date: Sat, Oct 26 2013 12:35 am
From: Bo Persson


Geoff skrev 2013-10-26 02:49:
> On Fri, 25 Oct 2013 15:55:04 -0700 (PDT), woodbrian77@gmail.com wrote:
>
>> One reason I'm opposed to Obamacare is people should be
>> free to associate with those they choose as far as
>> health care.
>
> The fundamental problem with national health care is the coercion. You
> will be fined or harassed until you join the lemmings.
>

Yeah, that's the point - everyone is covered.

The argument that some of you could get better care if others get
nothing doesn't really bite on non-Americans.


Bo Persson





== 8 of 11 ==
Date: Sat, Oct 26 2013 1:01 am
From: Geoff


On Sat, 26 Oct 2013 09:35:47 +0200, Bo Persson <bop@gmb.dk> wrote:

>Geoff skrev 2013-10-26 02:49:
>> On Fri, 25 Oct 2013 15:55:04 -0700 (PDT), woodbrian77@gmail.com wrote:
>>
>>> One reason I'm opposed to Obamacare is people should be
>>> free to associate with those they choose as far as
>>> health care.
>>
>> The fundamental problem with national health care is the coercion. You
>> will be fined or harassed until you join the lemmings.
>>
>
>Yeah, that's the point - everyone is covered.
>
>The argument that some of you could get better care if others get
>nothing doesn't really bite on non-Americans.
>
>

Actually, those others don't get "nothing". They get the same
treatment now as they would under Obamacare. No hospital refuses care
based on ability to pay. If you walk into ER and need surgery, you get
it, then and there if necessary. The hospitals make up for the lost
revenue by increasing the charges for those with insurance.

Under the new plan, those who cannot afford to pay the premiums will
be subsidized, whose who can pay more will be paying larger premiums
up front. Socialism is complete, redistribution is done by the central
government and the nanny state is in charge, like it or not.

Why should there be a requirement to "buy in" at all? Simply use the
money collected by income taxes to pay for it all.




== 9 of 11 ==
Date: Sat, Oct 26 2013 10:16 am
From: woodbrian77@gmail.com


On Saturday, October 26, 2013 2:35:47 AM UTC-5, Bo Persson wrote:
>
> Yeah, that's the point - everyone is covered.
>
> The argument that some of you could get better care if others get
> nothing doesn't really bite on non-Americans.
>

As I see it this is a little bit of Obama's record:

Number of people on food stamps is up 12 million
Record poverty
Debt to GDP ratio has increased

He has sucked in so many ways. I don't trust him
and wouldn't vote for him if he were running for
dog catcher.




== 10 of 11 ==
Date: Sat, Oct 26 2013 11:08 am
From: "brad"



"Geoff" <geoff@invalid.invalid> wrote in message
news:chsm699pl5mmh9bl9n2hqepqkqhn329mio@4ax.com...
> On Sat, 26 Oct 2013 09:35:47 +0200, Bo Persson <bop@gmb.dk> wrote:
>
>>Geoff skrev 2013-10-26 02:49:
>>> On Fri, 25 Oct 2013 15:55:04 -0700 (PDT), woodbrian77@gmail.com wrote:
>>>
>>>> One reason I'm opposed to Obamacare is people should be
>>>> free to associate with those they choose as far as
>>>> health care.
>>>
>>> The fundamental problem with national health care is the coercion. You
>>> will be fined or harassed until you join the lemmings.
>>>
>>
>>Yeah, that's the point - everyone is covered.
>>
>>The argument that some of you could get better care if others get
>>nothing doesn't really bite on non-Americans.
>>
>>
>
> Actually, those others don't get "nothing". They get the same
> treatment now as they would under Obamacare. No hospital refuses care
> based on ability to pay. If you walk into ER and need surgery, you get
> it, then and there if necessary. The hospitals make up for the lost
> revenue by increasing the charges for those with insurance.
>
> Under the new plan, those who cannot afford to pay the premiums will
> be subsidized, whose who can pay more will be paying larger premiums
> up front. Socialism is complete, redistribution is done by the central
> government and the nanny state is in charge, like it or not.
>
> Why should there be a requirement to "buy in" at all? Simply use the
> money collected by income taxes to pay for it all.

The people who are really getting screwed over by this are the young people.
The law say that the insurance rate for a 64 year old, obese, alcoholic can
be no more than three times the rate for a fit 21 year old with a healthy
life style. The number 3 was arrived at, mostly, by a bunch of guys who
went to law school but barely practiced law, not actuaries. Except for when
I was in the army I never went to a doctor even once until I was in my
fifties. Many years ago, health care was 10% of the GNP, I am sure the
proportion has grown a lot since then. Of course, much of that 10% already
came from the government in the form of Medicaid and Medicare, now the young
can, and will, supplement that source.

The young are also being screwed by the debt thing. Someday, the Chinese
are going to want actual money, not a new IOU to replace the current one.
Who is going to live through that inflationary period? Same guys.






== 11 of 11 ==
Date: Sat, Oct 26 2013 9:08 pm
From: Geoff


On Sat, 26 Oct 2013 13:08:44 -0500, "brad" <noise@comcast.net> wrote:

>
>"Geoff" <geoff@invalid.invalid> wrote in message
>news:chsm699pl5mmh9bl9n2hqepqkqhn329mio@4ax.com...
>> On Sat, 26 Oct 2013 09:35:47 +0200, Bo Persson <bop@gmb.dk> wrote:
>>
>>>Geoff skrev 2013-10-26 02:49:
>>>> On Fri, 25 Oct 2013 15:55:04 -0700 (PDT), woodbrian77@gmail.com wrote:
>>>>
>>>>> One reason I'm opposed to Obamacare is people should be
>>>>> free to associate with those they choose as far as
>>>>> health care.
>>>>
>>>> The fundamental problem with national health care is the coercion. You
>>>> will be fined or harassed until you join the lemmings.
>>>>
>>>
>>>Yeah, that's the point - everyone is covered.
>>>
>>>The argument that some of you could get better care if others get
>>>nothing doesn't really bite on non-Americans.
>>>
>>>
>>
>> Actually, those others don't get "nothing". They get the same
>> treatment now as they would under Obamacare. No hospital refuses care
>> based on ability to pay. If you walk into ER and need surgery, you get
>> it, then and there if necessary. The hospitals make up for the lost
>> revenue by increasing the charges for those with insurance.
>>
>> Under the new plan, those who cannot afford to pay the premiums will
>> be subsidized, whose who can pay more will be paying larger premiums
>> up front. Socialism is complete, redistribution is done by the central
>> government and the nanny state is in charge, like it or not.
>>
>> Why should there be a requirement to "buy in" at all? Simply use the
>> money collected by income taxes to pay for it all.
>
>The people who are really getting screwed over by this are the young people.
>The law say that the insurance rate for a 64 year old, obese, alcoholic can
>be no more than three times the rate for a fit 21 year old with a healthy
>life style. The number 3 was arrived at, mostly, by a bunch of guys who
>went to law school but barely practiced law, not actuaries. Except for when
>I was in the army I never went to a doctor even once until I was in my
>fifties. Many years ago, health care was 10% of the GNP, I am sure the
>proportion has grown a lot since then. Of course, much of that 10% already
>came from the government in the form of Medicaid and Medicare, now the young
>can, and will, supplement that source.
>
>The young are also being screwed by the debt thing. Someday, the Chinese
>are going to want actual money, not a new IOU to replace the current one.
>Who is going to live through that inflationary period? Same guys.
>

Yep, same here. In retrospect I would have used doctors more. When I
was 24 I was paying premiums for services I wasn't using. They count
on that. But I was the young buck back then, paying for the older
guys' retirements and pensions and now I have to fund my own with
401(k) and IRA money and there's no pension fund to rely on because
they liquidated or stole it all. Now I'm 59 and seeing a doctor every
two months to be sure the 6 medications I'm taking for heart disease
aren't killing my liver.

It always sucks to be young and penniless and paying someone else's
debt. Then it sucks to be old and tired and paying someone else's
debt. Then you die and they collect all your wealth and pay someone
else's debt.





==============================================================================
TOPIC: static function in named namespace
http://groups.google.com/group/comp.lang.c++/t/97c149400be76b3b?hl=en
==============================================================================

== 1 of 4 ==
Date: Sat, Oct 26 2013 5:42 am
From: Tobias Müller


Jorgen Grahn <grahn+nntp@snipabacken.se> wrote:
> On Wed, 2013-10-23, Tobias Müller wrote:
>> Jorgen Grahn <grahn+nntp@snipabacken.se> wrote:
>>
>> [...]
>>
>>> I don't have any
>>> major problems with your way, but I don't want most of my code to be
>>> indented.
>>
>> I don't indent namespaces anyway. Usually I don't have more than one
>> namespace in a file so I don't see any advantage in it.
>
> Yeah, that was something I considered doing for a while. In the end
> it boiled down to "I don't want others to have to fight their editor
> about the indentation" and "I don't want to learn how to train Emacs
> not to indent namespaces".

In my experience this is only a problem when inserting something at the
very beginning of the namespace. At least Visual Studio only considers the
local context when indenting.
Except when you autoformat the whole file of course, but I almost never do
that.

> (On the other hand I'm not consistent: Emacs wants to indent 'extern
> "C"' blocks and that's clearly crazy from a C perspective.)

You mean because of the usual #ifdef __cplusplus guards?
Conditional compilation like that makes "correct" indenting impossible
anyway.

Tobi




== 2 of 4 ==
Date: Sat, Oct 26 2013 9:00 am
From: Jorgen Grahn


On Sat, 2013-10-26, Tobias Müller wrote:
> Jorgen Grahn <grahn+nntp@snipabacken.se> wrote:
>> On Wed, 2013-10-23, Tobias Müller wrote:
>>> Jorgen Grahn <grahn+nntp@snipabacken.se> wrote:
>>>
>>> [...]
>>>
>>>> I don't have any
>>>> major problems with your way, but I don't want most of my code to be
>>>> indented.
>>>
>>> I don't indent namespaces anyway. Usually I don't have more than one
>>> namespace in a file so I don't see any advantage in it.
>>
>> Yeah, that was something I considered doing for a while. In the end
>> it boiled down to "I don't want others to have to fight their editor
>> about the indentation" and "I don't want to learn how to train Emacs
>> not to indent namespaces".
>
> In my experience this is only a problem when inserting something at the
> very beginning of the namespace. At least Visual Studio only considers the
> local context when indenting.
> Except when you autoformat the whole file of course, but I almost never do
> that.
>
>> (On the other hand I'm not consistent: Emacs wants to indent 'extern
>> "C"' blocks and that's clearly crazy from a C perspective.)
>
> You mean because of the usual #ifdef __cplusplus guards?
> Conditional compilation like that makes "correct" indenting impossible
> anyway.

I meant it's "clearly crazy" because you want to distract C users of
your header file as little as possible, so they don't petition you to
drop C++ compatibility ...

At least with Emacs, I don't think the indenting logic looks at
#ifdefs at all.

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .




== 3 of 4 ==
Date: Sun, Oct 27 2013 1:57 am
From: Rupert Swarbrick


Jorgen Grahn <grahn+nntp@snipabacken.se> writes:
> At least with Emacs, I don't think the indenting logic looks at
> #ifdefs at all.

The curly bracket in

extern "C" {

makes Emacs indent the following line. But if you manually put the first
declaration at column zero, Emacs "does what you want" for following
ones.


Rupert




== 4 of 4 ==
Date: Sun, Oct 27 2013 1:56 am
From: Rupert Swarbrick


Jorgen Grahn <grahn+nntp@snipabacken.se> writes:
> At least with Emacs, I don't think the indenting logic looks at
> #ifdefs at all.

The curly bracket in

extern "C" {

makes Emacs indent the following line. But if you manually put the first
declaration at column zero, Emacs "does what you want" for following
ones.


Rupert





==============================================================================
TOPIC: Can straight line est fit with error measure be made in single pass?
http://groups.google.com/group/comp.lang.c++/t/9d315080851a97ca?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Oct 26 2013 10:55 am
From: Richard Damon


On 10/23/13, 8:59 AM, SG wrote:
> On Saturday, October 19, 2013 3:57:36 AM UTC+2, Alf P. Steinbach wrote:
>> It would be nice if one could make do with a non-copyable forward
>> iterator for the (x,y) data points, without storing the points.
>
> Let me just mention that this extends to any linear least squares
> problem. The amount of memory you really need is just determined by
> the number of unknowns, not the number of "data points". Suppose
>
> A x = b
>
> is an overdetermined linear equation system with very few unknowns
> (and hence very hew columns in A) but many equations (rows in A).
> Then, you can, for example, compute A^T A and A^T b of
>
> A^T A x = A^T b // Gauss' normal equation system
>
> using a single loop over all rows of A and b. A^T A will be a small
> square matrix with n^2 entries where n is the number of unknowns.
> This can then be solved with a Cholesky factorization, for example.
>
> Other approaches are possible, too. If you care about numerical
> accuracy you could "accumulate" a couple of rows and periorically
> reduce the whole system to O(n^2) memory via Householder
> transformations.
>
> Cheers!
> SG
>

Note that Least Square fits are NOT overdetermined linear equations. You
do not get a "equation" for each data point when processing, but a
multidimensional optimization problem, with one dimension for each
unknown to find. This tends to be converted to a set of equations by
taking the partial derivative of the error over each coefficient to
solve for and finding the location where all the derivatives are zero.
What is helpful is that for a large class of problems, you don't need to
keep all the data points to solve the system, but can reduce the data
points to a limited number of moments, that the solution is based on.





==============================================================================
TOPIC: String class and the use of char*/const char*
http://groups.google.com/group/comp.lang.c++/t/deff4cb6c8ab6f38?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Oct 26 2013 11:31 am
From: Marcel Müller


On 23.10.13 11.17, goran.pusic@gmail.com wrote:
> Hi all,
>
> we seem to be having a style issue in the team.
>
> We have a string class that has char* and const char* conversion operators

operator const char* is mostly fine, but as soon as you implement
operator char* your code is close to death. There are hundreds of
drawbacks. Most importantly your code can easily have undefined behavior
where no compiler can give you any warnings or errors. (Believe me, I
have written some string classes so far.)

From my experience as soon as a C++ program uses char* (without const)
is is mostly buggy. For instance it is likely to have buffer overrun
vulnerabilities.

> (yes, i know we should be using std::string, please bear with me).

I, know, std::string is not always an option.

> Some people in the team prefer that, when calling code like this:
>
> retval func(..., const char* param, ...);
>
> with an instance of our string class, we use an explicit cast, e.g.

As I said, const char* is mostly safe. You only have to check for
dangling references, but no more than with that C API anyway.


> mystring s(whatever);
> func(..., (const char*)s, ...);

This cast is the worst case, since i would also cast mystring* or
whatever to (const char*). Things you usually don't want to do without a
compiler warning.

The common way is to provide a conversion function like c_str().


> Can I please have your opinion on this (good/bad/like/not like)? Insight?
> (My purpose, obviously, is to show your responses to the team).

- Remove operator char*.
- Remove char* from the C** source wherever possible.
- If you really need to adopt C APIs with char* without O(n) copies
provide a function like char* mystring::allocate(size_t length) that
ensures length+1 writeable characters until any other non-const mystring
function call for this instance while s[length] should not receive
anything but \0.


Marcel





==============================================================================
TOPIC: Request for build feedback
http://groups.google.com/group/comp.lang.c++/t/dc0fd05b60e1fac5?hl=en
==============================================================================

== 1 of 5 ==
Date: Sat, Oct 26 2013 1:54 pm
From: woodbrian77@gmail.com


On Thursday, July 25, 2013 9:49:22 PM UTC-5, woodb...@gmail.com wrote:
> On Thursday, July 25, 2013 6:40:12 PM UTC-5, woodb...@gmail.com wrote:
> >
>
> > The file to download is 21,059 bytes at this time so
> > downloading it shouldn't take long. On my Linux system
> > the library and two programs build in 9 seconds.
>
> I guess it's more like 7 seconds here.
>

I'm happy to report that the software builds consistently
now in under 6 seconds. This is on the same hardware and
with the same compiler as I used in July. I've made a number
of changes to the software since July that have improved the
build time.

http://webEbenezer.net/build_integration.html


I beleive the software is well written, but there is
probably room for some improvement.




== 2 of 5 ==
Date: Sat, Oct 26 2013 2:26 pm
From: Leigh Johnston


On 26/10/2013 21:54, woodbrian77@gmail.com wrote:
> On Thursday, July 25, 2013 9:49:22 PM UTC-5, woodb...@gmail.com wrote:
>> On Thursday, July 25, 2013 6:40:12 PM UTC-5, woodb...@gmail.com wrote:
>>>
>>
>>> The file to download is 21,059 bytes at this time so
>>> downloading it shouldn't take long. On my Linux system
>>> the library and two programs build in 9 seconds.
>>
>> I guess it's more like 7 seconds here.
>>
>
> I'm happy to report that the software builds consistently
> now in under 6 seconds. This is on the same hardware and
> with the same compiler as I used in July. I've made a number
> of changes to the software since July that have improved the
> build time.
>
> http://webEbenezer.net/build_integration.html
>
>
> I beleive the software is well written, but there is
> probably room for some improvement.

Hello Mr Homophobic Bigot. Where is your usual god bothering .sig?

Haven't you noticed that nobody on Usenet cares about your fucking
library yet? Best your posts on it do is start stupid discussions about
misuse of namespaces.

Lose the bigotry and go make something useful.

/Leigh





== 3 of 5 ==
Date: Sat, Oct 26 2013 3:21 pm
From: woodbrian77@gmail.com


On Saturday, October 26, 2013 4:26:14 PM UTC-5, Leigh Johnston wrote:


Please don't swear here.

I gave this thread an update in part because there are
new people rolling through here from time to time.

If you have some technical criticism of the software I'd
be happy to hear it.




== 4 of 5 ==
Date: Sun, Oct 27 2013 6:23 am
From: Leigh Johnston


On 26/10/2013 23:21, woodbrian77@gmail.com wrote:
> On Saturday, October 26, 2013 4:26:14 PM UTC-5, Leigh Johnston wrote:
>
>
> Please don't swear here.

Do you seriously believe that asking nicely will stop people swearing in
here you cunt?

>
> I gave this thread an update in part because there are
> new people rolling through here from time to time.

But your posts about it are usually random and inane like "my
compilation time changed by a second". Usenet is not your own personal
diary.

>
> If you have some technical criticism of the software I'd
> be happy to hear it.

Given your posts on it it seems like it is not a serious piece of
software from a not so serious company run by a misogynist, homophobic
bigoted god bothering lunatic.

/Leigh





== 5 of 5 ==
Date: Sun, Oct 27 2013 9:42 am
From: woodbrian77@gmail.com


On Sunday, October 27, 2013 8:23:27 AM UTC-5, Leigh Johnston wrote:
> On 26/10/2013 23:21, woodbrian77@gmail.com wrote:
>
> > On Saturday, October 26, 2013 4:26:14 PM UTC-5, Leigh Johnston wrote:
>
> >
>
> >
>
> > Please don't swear here.
>
>
>
> Do you seriously believe that asking nicely will stop people swearing

Yes, and please don't use sexual slurs here.

>
> >
>
> > I gave this thread an update in part because there are
> > new people rolling through here from time to time.
>
> But your posts about it are usually random and inane like "my
> compilation time changed by a second".

The software was good in July and is better now.

> Usenet is not your own personal
> diary.
>

Remember this part of Psalm 23.

5 You prepare a table before me in the presence of my enemies;
You have anointed my head with oil;
My cup overflows.
6 Surely goodness and lovingkindness will follow me all
the days of my life,
And I will dwell in the house of the L-rd forever.


And then bring in "One man's trash is another man's treasure."
My software may be trash to you, but to poverty stricken
people from India, China, Russia, Nepal. Egypt, Greece, Spain,
Mexico etc., it's a lifesaver. Why? Because it's free and
of increasingly high quality. G-d's will is to help His people
and they are all over the globe.





==============================================================================
TOPIC: Integer arithmetic when overflow exists
http://groups.google.com/group/comp.lang.c++/t/817dc36a142b4ac5?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, Oct 27 2013 7:58 am
From: Rosario1903


On Mon, 14 Oct 2013 14:28:37 -0500, Paavo Helde wrote:

>So far, it seems that the strongest point for putting the wrap-over into
>the standard is that otherwise a bunch of x86 and other assembler
>programmers might have some misconceptions about C++.

it is not wrapp aroudn to put in the standard is overflwo flag

>Why should we care
>so much about assembler programmers?

yes why care c++s? :)
....
>No problem, I think gcc won't optimize in debug mode and will catch my UB
>in the debug mode (i am regularly running the tests in debug mode, in
>addition to the automatic release mode testing).
....
>All tests are run after each commit, in the continous integration builds.
>No problem here, other than that we don't yet have 100% code coverage in
>tests. So I will probably switch off this flag in the stable branch
>(actually delivered to customers) in order to avoid false positives at
>customer site.

in assembly, if it would be possible some overflow, i would detect
it...
i don't know how big programmers do it etc

>Cheers
>Paavo




==============================================================================

You received this message because you are subscribed to the Google Groups "comp.lang.c++"
group.

To post to this group, visit http://groups.google.com/group/comp.lang.c++?hl=en

To unsubscribe from this group, send email to comp.lang.c+++unsubscribe@googlegroups.com

To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.c++/subscribe?hl=en

To report abuse, send email explaining the problem to abuse@googlegroups.com

==============================================================================
Google Groups: http://groups.google.com/?hl=en

Wednesday, October 23, 2013

comp.lang.c++ - 26 new messages in 10 topics - digest

comp.lang.c++
http://groups.google.com/group/comp.lang.c++?hl=en

comp.lang.c++@googlegroups.com

Today's topics:

* scoped enum issue with MS VS C++ - 4 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/bc3736cc883fcf53?hl=en
* Question regarding copy constructor - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/9e723534f9e94458?hl=en
* A simpler Pimpl Idiom ? - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/8c62d669bf4e1562?hl=en
* More C++ 11 questions regarding array - 4 messages, 4 authors
http://groups.google.com/group/comp.lang.c++/t/28c60ed4660dfce6?hl=en
* String and interfacing with functions using char* - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/a7d848d28878a317?hl=en
* Array Size - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/a6377bc32796137b?hl=en
* Follow-up Pimpl question - 4 messages, 4 authors
http://groups.google.com/group/comp.lang.c++/t/c4cad0c102a54739?hl=en
* Function for arrays - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/466519b3df961798?hl=en
* What to C++ 11 features to cover in my C++ courses? - 4 messages, 4 authors
http://groups.google.com/group/comp.lang.c++/t/351a8b3595621c91?hl=en
* Symbol already defined acting differently for class methods? - 2 messages, 2
authors
http://groups.google.com/group/comp.lang.c++/t/52d45470aea1e966?hl=en

==============================================================================
TOPIC: scoped enum issue with MS VS C++
http://groups.google.com/group/comp.lang.c++/t/bc3736cc883fcf53?hl=en
==============================================================================

== 1 of 4 ==
Date: Mon, Oct 21 2013 11:37 am
From: bobl0456@gmail.com


I get the following error:

TurtleGraphics.cpp(93): error C2677: binary '!=' : no global operator found which takes type 'Cmds' (or there is no acceptable conversion)

for the following statement:

} while ( cmdsArray[cmdNo] != Cmds::END_OF_DATA ); // repeat until end of data reached

Cmds is defined as:

enum class Cmds { PEN_UP = 1, PEN_DWN, TURN_RIGHT, TURN_LEFT, MOVE, DISPLAY, END_OF_DATA = 9};

and cmdsArray is a pointer based array of type int.

I do not understand why this should not work. BTW, I know that if I change the enum back to traditional unscoped enum it will work fine.

Bob






== 2 of 4 ==
Date: Mon, Oct 21 2013 11:47 am
From: "Alf P. Steinbach"


On 21.10.2013 20:37, bobl0456@gmail.com wrote:
> I get the following error:
>
> TurtleGraphics.cpp(93): error C2677: binary '!=' : no global operator found which takes type 'Cmds' (or there is no acceptable conversion)
>
> for the following statement:
>
> } while ( cmdsArray[cmdNo] != Cmds::END_OF_DATA ); // repeat until end of data reached
>
> Cmds is defined as:
>
> enum class Cmds { PEN_UP = 1, PEN_DWN, TURN_RIGHT, TURN_LEFT, MOVE, DISPLAY, END_OF_DATA = 9};
>
> and cmdsArray is a pointer based array of type int.
>
> I do not understand why this should not work.

Using the word "class" you asked for a bit stronger type checking.

You got it.


> BTW, I know that if I change the enum back to traditional unscoped enum it will work fine.

Instead, fix the array type.


Cheers & hth.,

- Alf

PS: Using ALL UPPERCASE for constants is a Java convention. In C++ ALL
UPPERCASE is conventionally reserved for macro names, in order to reduce
the chance of name collisions and unintended text substitution. Java
doesn't have macros. Using such names for mere constants, as in Java, in
C++ increases the chance of name collisions and unintended text
substitution, i.e. it's /directly in conflict/ with the common C++
convention. It's also an all out visual attack, hurting the eyes. And
ears. :(





== 3 of 4 ==
Date: Mon, Oct 21 2013 12:02 pm
From: kfrank29.c@gmail.com


Hi Bob!

I can't comment specifically on the microsoft compiler,
but it appears to be acting according to the standard.

On Monday, October 21, 2013 2:37:06 PM UTC-4, bobl...@gmail.com wrote:
> I get the following error:
>
> TurtleGraphics.cpp(93): error C2677: binary '!=' : no global operator found which takes type 'Cmds' (or there is no acceptable conversion)
>
> for the following statement:
>
> } while ( cmdsArray[cmdNo] != Cmds::END_OF_DATA ); // repeat until end of data reached
>
> Cmds is defined as:
>
> enum class Cmds { PEN_UP = 1, PEN_DWN, TURN_RIGHT, TURN_LEFT, MOVE, DISPLAY, END_OF_DATA = 9};
>
> and cmdsArray is a pointer based array of type int.
>
> I do not understand why this should not work. BTW, I know that if I change the enum back to traditional unscoped enum it will work fine.

The key issue is that enum classes (scoped enums)
in c++11 do not implicitly convert to ints (unlike
"traditional" enums).

Let me quote from Stroustrup's (very useful) c++11 faq:

http://www.stroustrup.com/C++11FAQ.html#enum

The enum classes ("new enums", "strong enums") address
three problems with traditional C++ enumerations:

conventional enums implicitly convert to int, causing errors
when someone does not want an enumeration to act as an integer.

So, this is a feature (that I almost agree with), not
a bug.

Also not the further comment in the faq:

In the standard library, enum classes are used
...
Several of these have operators, such as == defined.

Reading between the lines a little here you can make
it possible to test your enum class against an int for
equality or inequality, but to do so you have to provide
your own operator==() and/or operator!=().

(But following Alf's suggestion, probably the most direct
fix to your current issue is to make cmdsArray an array
of Cmds rather than int.

> Bob


Happy C++11 Hacking!


K. Frank




== 4 of 4 ==
Date: Mon, Oct 21 2013 1:17 pm
From: bobl0456@gmail.com


Thanks for the responses.

Bob






==============================================================================
TOPIC: Question regarding copy constructor
http://groups.google.com/group/comp.lang.c++/t/9e723534f9e94458?hl=en
==============================================================================

== 1 of 2 ==
Date: Mon, Oct 21 2013 11:42 am
From: Tobias Müller


Öö Tiib <ootiib@hot.ee> wrote:
> On Monday, 21 October 2013 18:55:47 UTC+3, Tobias Müller wrote:
>> "K. Frank" <kfrank29.c@gmail.com> wrote:
>>
>> [...]
>>
>>> Given that in somenath's example, the constructor
>>> A(int) exists, and given that the compiler is
>>> allowed to copy-elide the copy constructor away,
>>> why does the standard _not_ define
>>>
>>> A a = 2;
>>>
>>> and
>>>
>>> A a(2);
>>>
>>> to be synonymous? That is, why not just define
>>> A a = 2 to be direct initialization, and be done
>>> with it?
>>>
>>> Given that the programmer cannot rely on the copy
>>> constructor getting called in this situation, I
>>> don't see any reason why letting the compiler
>>> first construct and then copy construct would be
>>> advantage. Wouldn't it be simpler and better (and
>>> fully backward compatible) just to require A a = 2
>>> to be direct initialization?
>>
>> Even more so as it is already a special case. Regarding only the syntax,
>> you would expect the appropriate assignment operator to be called.
>
> There certainly won't be assignment operators used in initialization.

Yes, that's what I wanted to say. Syntactically it's an assignment, but in
the context of a declaration it is special cased to actually mean
initialization. But then, why in a such convoluted way?

> Most coding standards suggest to write what you actually want 'A a(2);' and
> to avoid writing "likely synonymous after optimizations" variants.

The above proposal would provide exactly that. Without relying on
optimizations.
But I agree, just writing the appropriate constructor is even better.

Tobi




== 2 of 2 ==
Date: Mon, Oct 21 2013 12:38 pm
From: Victor Bazarov


On 10/21/2013 2:42 PM, Tobias Müller wrote:
> [..] Syntactically it's an assignment, but in
> the context of a declaration it is special cased to actually mean
> initialization. But then, why in a such convoluted way?

<shrug> Why not? This is one of C legacies. It's very likely that in a
function scope it literally meant the same machine code... And many an
older folk got used to seeing this form and keep using it. Imagine (a)
requiring to rewrite millions of lines(*) of

int a = 42;

to

int a { 42 };

and (b) force scores of thousands of C++ programmers to re-learn to use
that form from some point on... I don't think it's feasible.

>> [..]

*) I don't really know how many lines of such code exist and need to be
maintained, so might be off by a billion or two.

V
--
I do not respond to top-posted replies, please don't ask





==============================================================================
TOPIC: A simpler Pimpl Idiom ?
http://groups.google.com/group/comp.lang.c++/t/8c62d669bf4e1562?hl=en
==============================================================================

== 1 of 2 ==
Date: Mon, Oct 21 2013 12:05 pm
From: Tobias Müller


"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> wrote:
[...]
> Not sure if Herb mentions this, but the main purpose of a PIMPL is to
> encapsulate use of dirty or large or platform-specific (whatever)
> headers. If that's not a problem, then PIMPL is usually not needed. A
> main cost of PIMPL is that it requires separate compilation.

Separate compilation may be the main cost, but it's also one of the main
use case.
For software that comes only as binary + header it is convenient way for
hiding the implementation and maintaining binary compatibility.

>> How would one mark the class 'visible' an interface-only (it should
>> not be derived in user applications).
>
> For C++11, <url: http://en.cppreference.com/w/cpp/language/final>, using
> the keyword "final".

But then it is no more possible to derive 'invisible' from it neither. Or
am I missing something?

[...]

Tobi




== 2 of 2 ==
Date: Mon, Oct 21 2013 1:07 pm
From: Öö Tiib


On Monday, 21 October 2013 16:45:01 UTC+3, mathieu wrote:
> I have been reading "The Joy of Pimpls " [1], but this
> seems over-complicated IMHO. It requires a "back-pointer" just to
> split object in halves.

Additional indirection by that "back-pointer" is not as expensive as
lot of people seem to think, also it provides cheap swaps/moves for
free. So classical Pimpl is on lot of cases best thing.

If moving only private member functions to compilation-unit local
is the goal then that can be done without any pointers. I posted one way
how in March to comp.lang.c++.moderated:
header https://groups.google.com/d/msg/comp.lang.c++.moderated/GJyXgeEtAOA/PwXSG_ZGeGgJ

If you want to hide member data too AND want to get rid of that
pointer then in C++11 you can just have sufficient buffer for private
implementation in class. Verify that it is sufficient in compilation-unit
using C++11 'static_assert', 'alignas', 'alignof' and 'sizeof'.
Then you have to use placement new, explicit destructor calls and
reinterpret_cast to manage private implementation in that buffer.
Without C++11 one can use compiler extensions to achieve same (lot of
stuff in Boost have done it for decade).

IOW your implementation has numerous limitations that are not needed and
can be easily avoided. ;)





==============================================================================
TOPIC: More C++ 11 questions regarding array
http://groups.google.com/group/comp.lang.c++/t/28c60ed4660dfce6?hl=en
==============================================================================

== 1 of 4 ==
Date: Mon, Oct 21 2013 12:35 pm
From: bobl0456@gmail.com


Correct me if I am wrong, but there seems to be a least 2 short comings (at least to my view point) to using std::array :

1) no equivalent to

int myArray[] = { a very long list of values too long to conveniently count };

2) no equivalent to

void func (int[], int[][3] );

in other words, when converted to an std::array we need to specify the size of all of the dimensions of arrays passed to a function.

Am I correct on these 2 points? Or are there acceptable workarounds or syntax I am not aware of?

Thanks,
Bob




== 2 of 4 ==
Date: Mon, Oct 21 2013 1:29 pm
From: Öö Tiib


On Monday, 21 October 2013 22:35:43 UTC+3, bobl...@gmail.com wrote:
> Correct me if I am wrong, but there seems to be a least 2 short comings (at least to my view point) to using std::array :
>
> 1) no equivalent to
> int myArray[] = { a very long list of values too long to conveniently count };

Correct. That is the sole shortcoming and such long arrays are rare and
usually immutable.

> 2) no equivalent to
>
> void func (int[], int[][3] );

Wrong. That declaration is /exactly/ equivalent to:

void func (int*, int(*)[3]);

No arrays are passed there, just pointers. 'std::array' can be converted
to pointer to underlying array with 'data()' but why? Just pass pointer
to 'std::array'.

> in other words, when converted to an std::array we need to specify the
> size of all of the dimensions of arrays passed to a function.

If the function does not know the dimensions then how can it dare to
touch the elements of array? Unsafe "hopefully it is OK"? That is common
source of errors. If it does know it then what is the problem to
indicate it in interface? If it should accept different arrays then
it can be made a template and if the arrays are made dynamically
then it is 'std::vector' (not 'std::array') that you need instead
anyway.




== 3 of 4 ==
Date: Mon, Oct 21 2013 1:33 pm
From: red floyd


On 10/21/2013 12:35 PM, bobl0456@gmail.com wrote:
> Correct me if I am wrong, but there seems to be a least 2 short comings (at least to my view point) to using std::array :
>
> 1) no equivalent to
>
> int myArray[] = { a very long list of values too long to conveniently count };
Not sure about this. I think you may need to know the size for the
template parameter.
>
> 2) no equivalent to
>
> void func (int[], int[][3] );

template<int N>
void func(std::array<int, N>, std::array<std::array<int, N>,3>);







== 4 of 4 ==
Date: Mon, Oct 21 2013 1:36 pm
From: "Alf P. Steinbach"


On 21.10.2013 21:35, bobl0456@gmail.com wrote:
> Correct me if I am wrong, but there seems to be a least 2 short comings (at least to my view point) to using std::array :
>
> 1) no equivalent to
>
> int myArray[] = { a very long list of values too long to conveniently count };

It's not difficult to work around, but it's definitely missing
functionality.

E.g. see my clc++ posting <url:
news:a12f9f2e-e414-45e8-9210-1f0543ffaa5c@googlegroups.com>, e.g. as
archived at
<url:
https://groups.google.com/d/msg/comp.lang.c++/0gGpBl6Bm54/3_tjMwXf2J0J>.

Which Visual C++ ICE reminds me to submit yet another bug report to
Microsoft. I just plain forgot about it. Also, reminds me of how Google
actively sabotages Usenet: in addition to dropped references, sabotage
of signature marker (you can't -- or couldn't -- post one via GG), no
threaded display, etc., Google Groups posts with QUOTED PRINTABLE. :(


> 2) no equivalent to
>
> void func (int[], int[][3] );
>
> in other words, when converted to an std::array we need to specify the size of all
> of the dimensions of arrays passed to a function.

Hm.


> Am I correct on these 2 points? Or are there acceptable workarounds or syntax I
> am not aware of?

For initialization, see above.


Cheers & hth.,

- Alf






==============================================================================
TOPIC: String and interfacing with functions using char*
http://groups.google.com/group/comp.lang.c++/t/a7d848d28878a317?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Oct 21 2013 12:57 pm
From: Seungbeom Kim


On 2013-10-20 09:04, James Kanze wrote:
>
> IIRC, emacs has a block mode which allows text insertion at
> logical positions where there is no text; it fills with blanks
> if needed. One of the few things I don't like about vim is that
> even in visual block mode, the visual cursor cannot be placed
> beyond the physical end of line.

Have you tried "set virtualedit=..." in Vim?
It seems to work exactly in the way you described for Emacs above.

--
Seungbeom Kim





==============================================================================
TOPIC: Array Size
http://groups.google.com/group/comp.lang.c++/t/a6377bc32796137b?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Oct 21 2013 1:43 pm
From: Seungbeom Kim


On 2013-06-22 09:44, Leigh Johnston wrote:
>
> Bad engineering practice my arse; you simply use a cast in the
> appropriate place and if you forget to cast and are using abs then the
> compiler will complain:
>
> int main()
> {
> typedef unsigned int length_t;
> typedef int difference_t;
> length_t a = 42;
> length_t b = 2;
> std::cout << "42 - 2 = " << abs(static_cast<difference_t>(a - b)) << std::endl;
> std::cout << "2 - 42 = " << abs(static_cast<difference_t>(b - a)) << std::endl;
> }

This relies on the implementation-defined conversion to a signed
integral type of an out-of-range value. The proper way is:

abs(static_cast<difference_t>(a) - static_cast<difference_t>(b))

assuming, of course, that a and b are in the range for difference_t.

--
Seungbeom Kim





==============================================================================
TOPIC: Follow-up Pimpl question
http://groups.google.com/group/comp.lang.c++/t/c4cad0c102a54739?hl=en
==============================================================================

== 1 of 4 ==
Date: Mon, Oct 21 2013 3:39 pm
From: Rupert Swarbrick


I'm coming back to writing some C++ after a few years in Lisp-land, and
was wondering about the "pimpl idiom". I understand how to write and use
it, and have done in the past. However, I don't really understand what
it gains you over having an abstract base class in the header, along
with a factory function.

Presumably there's a significant difference, since people put up with
the reams of boilerplate required for passing functions through to the
implementation object. Can anyone explain to me what it is?


Rupert


PS: I'm not sure whether there are strong feelings about whether to use
this idiom or not. To be clear, I'm not trying to hear them! I can
see obvious downsides to keeping a pointer to an implementation
object (verbosity; have to be careful about destructor +
exceptions...) and I'm interested to know what the upsides are.




== 2 of 4 ==
Date: Mon, Oct 21 2013 6:07 pm
From: "K. Frank"


Hello Rupert!

On Monday, October 21, 2013 6:39:27 PM UTC-4, Rupert Swarbrick wrote:
> I'm coming back to writing some C++ after a few years in Lisp-land, and
> was wondering about the "pimpl idiom". I understand how to write and use
> it, and have done in the past. However, I don't really understand what
> it gains you over having an abstract base class in the header, along
> with a factory function.
>
> Presumably there's a significant difference, since people put up with
> the reams of boilerplate required for passing functions through to the
> implementation object. Can anyone explain to me what it is?

Well, first off, as you recognize, there is cost to
using the pimpl idiom, and I certainly won't argue
that it is always desirable of preferable.

However, one benefit is that for some use cases
constructors and destructors are very useful tools.

In particular they let you have local instances of
classes on the stack and those instances get cleaned
up automatically -- their destructors called -- when
they go out scope, even if scope is exited because
an exception was thrown. This is the main reason
that RAII plus executions / stack unwinding is so
powerful.

Of course there are other ways of achieving this.
For example you could use a smart pointer and a
factory function (but one might argue that doing
so is just reimplementing the pimpl idiom by another
name).

> Rupert
> ...


Good luck.


K. Frank




== 3 of 4 ==
Date: Mon, Oct 21 2013 7:36 pm
From: Öö Tiib


On Tuesday, 22 October 2013 01:39:27 UTC+3, Rupert Swarbrick wrote:
> I'm coming back to writing some C++ after a few years in Lisp-land, and
> was wondering about the "pimpl idiom". I understand how to write and use
> it, and have done in the past. However, I don't really understand what
> it gains you over having an abstract base class in the header, along
> with a factory function.

We call it "pimpl" since we like Orcish language perhaps, rest call it
"Cheshire Cat", "Compiler firewall" or "Bridge pattern".

There is better separation of concerns. Abstraction implements external
interface. Implementor implements internal implementation.

There are more dynamics. For example when object behind pointer to
interface is made then it can not change its type anymore in C++.
The implementor that is behind abstraction of pimpl however may be
is dynamically replaced, shared, cached, reused or copied-on-write etc.
by abstraction. It is not business of user of abstraction but
externally it may feel like type has changed entirely during life-time
of abstraction.

Slight performance advantage of pimpl is that the virtual functions
are not needed. There may be virtual functions as implementor may be
polymorphic ... but those are not mandatory. So virtual functions
may be used when those improve performance, not when they describe
common interface.

> Presumably there's a significant difference, since people put up with
> the reams of boilerplate required for passing functions through to the
> implementation object. Can anyone explain to me what it is?

It is never clear if any of named advantages is substantial enough for
you.

> PS: I'm not sure whether there are strong feelings about whether to use
> this idiom or not. To be clear, I'm not trying to hear them! I can
> see obvious downsides to keeping a pointer to an implementation
> object (verbosity; have to be careful about destructor +
> exceptions...) and I'm interested to know what the upsides are.

I must say that pimpl has its downsides too. If the problem has simple
solution then it is easy to make it more complex by adding unneeded
pimpl. We should aim to keep things as simple as possible (just not
simpler than possible). So pimpl is good for complex enough objects.




== 4 of 4 ==
Date: Mon, Oct 21 2013 10:41 pm
From: Tobias Müller


Rupert Swarbrick <rswarbrick@gmail.com> wrote:
> I'm coming back to writing some C++ after a few years in Lisp-land, and
> was wondering about the "pimpl idiom". I understand how to write and use
> it, and have done in the past. However, I don't really understand what
> it gains you over having an abstract base class in the header, along
> with a factory function.
>
> Presumably there's a significant difference, since people put up with
> the reams of boilerplate required for passing functions through to the
> implementation object. Can anyone explain to me what it is?
>
>
> Rupert
>
>
> PS: I'm not sure whether there are strong feelings about whether to use
> this idiom or not. To be clear, I'm not trying to hear them! I can
> see obvious downsides to keeping a pointer to an implementation
> object (verbosity; have to be careful about destructor +
> exceptions...) and I'm interested to know what the upsides are.

IMO the abstract base class pattern is not the right solution for this
problem. It may work as long as your objects are only given out, and never
taken back.
As soon as you have a method taking the abstract base class as parameter it
is not safe anymore.
While the method is formally taking an abstract base class, it actually
expects your concrete subclass instead (and must resort to casting).
I know no way for restricting a class to only be derived once. There is
nothing (except documentation) that prevents the client code from deriving
from your abstract base class and pass such an object to your method.

It is just an incomplete solution to the problem. OTOH, pimpl objects
behave like normal C++ objects in every single aspect. As long as you
restrict yourself to the public interface you could use the pimpl class as
a drop-in replacement of the actual implementation.

Tobi





==============================================================================
TOPIC: Function for arrays
http://groups.google.com/group/comp.lang.c++/t/466519b3df961798?hl=en
==============================================================================

== 1 of 2 ==
Date: Mon, Oct 21 2013 7:45 pm
From: axcytz@gmail.com


Hi all,

I have an array containing 10 elements in it. I want to swap all elements (2 swap) with each other after each swap I will calculate a function value based on the updated array. So, I will have 45 different function values (10 choose 2). I will store these values in another array and will get the index of the smallest valued array.

This is what i want to do.

include<algortihm>

My function:


for(int i=0 ; i< 45; i++)
{
for(int j=0; j<10; j++)
{
for(int k=0; k<10; k++)
{
UpdatedArray[i] = swap(MyArray[j], MyArray[k]);
FunctionValue[i] = Data[k]*Value[UpdatedArray]; //here the part after equal sign is not important for now.

}
}
}

Any help is appreciated, thanks!




== 2 of 2 ==
Date: Mon, Oct 21 2013 8:50 pm
From: "Alf P. Steinbach"


On 22.10.2013 04:45, axcytz@gmail.com wrote:
>
> I have an array containing 10 elements in it. I want to swap all elements
> (2 swap) with each other after each swap I will calculate a function value
> based on the updated array. So, I will have 45 different function values
> (10 choose 2). I will store these values in another array and will get the
> index of the smallest valued array.

OK so far.

This implies that you store information about which items were swapped.


> This is what i want to do.
>
> include<algortihm>
>
> My function:
>
>
> for(int i=0 ; i< 45; i++)
> {
> for(int j=0; j<10; j++)
> {
> for(int k=0; k<10; k++)
> {
> UpdatedArray[i] = swap(MyArray[j], MyArray[k]);
> FunctionValue[i] = Data[k]*Value[UpdatedArray]; //here the part after equal sign is not important for now.
>
> }
> }
> }
>
> Any help is appreciated, thanks!

Well the code above does NOT do what you described. It performs 4500
swaps, not 45. It swaps each pair twice. And it doesn't store the
function results.

To gain some clarity,

1. Reduce the array size to, say, 4. Which you can handle manually.

2. Think about how to do those swaps, systematically, BY HAND.
It's the system that's important.
But it's also important to actually try it out, by hand.

3. When you have managed to do it by hand (e.g. using small paper
squares to represent the array items), then try to express it in C++.

At that point it's time to perhaps post a new question here, or if
everything's clear, just proceed directly to computing and storing
function results.


Cheers & hth.,

- Alf (hoping that nobody will spoil your learning experience by posting
code showing how clever they are (not!), & wishing good luck)







==============================================================================
TOPIC: What to C++ 11 features to cover in my C++ courses?
http://groups.google.com/group/comp.lang.c++/t/351a8b3595621c91?hl=en
==============================================================================

== 1 of 4 ==
Date: Mon, Oct 21 2013 8:18 pm
From: bobl0456@gmail.com


Hi folks,

I am finally covering some of the new C++ features in my C++ course. I am interested in getting input from the C++ community as to the priority of new features to cover.

To give you some idea of the features I am planning to cover, these are some of the new features I plan to cover:

array container
auto for type inference
delegating ctors
explicit conversion operators
final classes
final member functions
inheriting base class ctors
list initialization changes
move assignment operator
move ctor
non-deterministic random number generation
nullptr
override keyword
range based for statement
regular expressions
rvalue references
scoped enums
shared_ptr smart pointer
unique_ptr smart pointer
weak_ptr smart pointer

I would appreciate advice on additional features I should cover and any of the above features you feel are unimportant.

TIA
Bob





== 2 of 4 ==
Date: Mon, Oct 21 2013 8:36 pm
From: "Alf P. Steinbach"


On 22.10.2013 05:18, bobl0456@gmail.com wrote:
> Hi folks,
>
> I am finally covering some of the new C++ features in my C++ course. I am interested in getting input from the C++ community as to the priority of new features to cover.
>
> To give you some idea of the features I am planning to cover, these are some of the new features I plan to cover:
>
> array container
> auto for type inference
> delegating ctors
> explicit conversion operators
> final classes
> final member functions
> inheriting base class ctors
> list initialization changes
> move assignment operator
> move ctor
> non-deterministic random number generation
> nullptr
> override keyword
> range based for statement
> regular expressions
> rvalue references
> scoped enums
> shared_ptr smart pointer
> unique_ptr smart pointer
> weak_ptr smart pointer
>
> I would appreciate advice on additional features I should cover and any of the above
> features you feel are unimportant.

The students should already be familiar with shared_ptr from their
experience with C++03, using boost::shared_ptr and/or the TR1 shared_ptr.

If not then you need to cover that first, it's C++03 stuff.

Then unique_ptr (pure C++11) as replacement for now deprecated auto_ptr.

That covers the most important FUNCTIONAL CHANGES of the language, how
to manage dynamically allocated objects.

Then, considering what I use most,

1. "auto" (especially for function declarations and constants),

2. rvalue references and move semantics with std::move, move
constructors and move assignment, and new conventions for argument
passing (by value is often very OK) and function results (not const)

3. std::function and lambdas


I use range-based loops all the time but if you have to choose, then as
above.

As a general guideline, use the teaching time on what the students need
to understand and can benefit from discussing, don't waste that time on
what they can simply read up in Wikipedia, blogs and the holy Standard
-- or MSDN Library -- even if a buzzword checklist might impress. ;-)


Cheers & hth.,

- Alf





== 3 of 4 ==
Date: Mon, Oct 21 2013 9:24 pm
From: woodbrian77@gmail.com


On Monday, October 21, 2013 10:18:23 PM UTC-5, bobl...@gmail.com wrote:
> Hi folks,
>
>
>
> I am finally covering some of the new C++ features in my C++ course. I am interested in getting input from the C++ community as to the priority of new features to cover.
>
>
>
> To give you some idea of the features I am planning to cover, these are some of the new features I plan to cover:
>
>
>
> array container
> auto for type inference
> delegating ctors
> list initialization changes
> move assignment operator
> move ctor
> nullptr
> range based for statement
> rvalue references
> scoped enums
> unique_ptr smart pointer
>

I use the above and also use non-static data member
initialization. I haven't come across the need for
shared_ptr. I haven't used explicit conversion
operator's, but am interested in learning about
that.

Brian
Ebenezer Enterprises - In G-d we trust.
http://webEbenezer.net




== 4 of 4 ==
Date: Tues, Oct 22 2013 6:05 am
From: "K. Frank"


Hi Bob!

On Monday, October 21, 2013 11:18:23 PM UTC-4, bobl...@...l.com wrote:
> Hi folks,
>
> I am finally covering some of the new C++ features in my C++ course.
> I am interested in getting input from the C++ community as to the
> priority of new features to cover.

First off, without knowing more about the context of your
course -- purpose, length, students' previous programming
experience, students' previous c++ experience -- it's hard
to give appropriate advice.

Also, it sounds like you're already well along in your course
and coming up to the c++11 section, so my answer is probably
too late.

But I would turn things around and just teach c++11 as c++,
and use various c++ features (including c++11 features) as
appropriate. The c++11 standard was ratified already a couple
of years ago, and largely complete drafts and compilers
supporting much of the new functionality were available
already a couple of years before that, so c++11 should hardly
be looked upon as some mysterious bleeding edge thing.

Quoting Stroustrup in his c++11 faq:

What do you think of C++11?

That's a (to me) amazingly frequent question. It may
be the most frequently asked question. Surprisingly,
C++11 feels like a new language: The pieces just fit
together better than they used to and I find a higher-
level style of programming more natural than before
and as efficient as ever.

(Of course, he's a partisan.)

Although they might be considered syntactic sugar, a lot of
c++11 features are there to make programming more convenient
on a routine, day-to-day basis. (I'm thinking of things
like auto, range-for, in-class initialization, uniform and
list initialization, etc.)

If we as a community continue to adopt cleaner, better c++11
idioms as opportunity permits, and encourage our colleagues
(and students) to do the same, the language in the field
will get -- well -- cleaner and better.

And what better place to start than in a c++ class.

So rather than teach students -- I won't call them bad,
but rather less-good -- pre-c++11 habits and then tack
on some c++11 features at the end of the course, why not
just teach c++11 best practices from day one?

I recognize that some will argue that a lot of real-world
c++ is pre-c++11, but a lot of real-world code is java,
and python, and c. So I say why not teach your student
the best, cleanest programming style and idioms, making
use of language features (whether c++11 or not) that
support that style and those idioms, even as we recognize
that students will come across, and sometimes need to work
with, other programming styles, dialects, and languages.

That's my perspective, at least, although it may not be
appropriate for the context and purpose of your specific
class.

> ...
> TIA
>
> Bob


Good luck.


K. Frank





==============================================================================
TOPIC: Symbol already defined acting differently for class methods?
http://groups.google.com/group/comp.lang.c++/t/52d45470aea1e966?hl=en
==============================================================================

== 1 of 2 ==
Date: Tues, Oct 22 2013 6:20 am
From: blazb


Why does the linker (gcc, msvc) not fail for the example below?

It complains for multiple definitions of function bar, but not for multiple definitions of function foo in class Foo.


"a.cpp"

#include <stdio.h>

void bar() {
puts("bar from a.cpp");
}

struct Foo {
char a[20];
void foo(){
puts("foo from a.cpp");
}
};

void test_b();

int main()
{
printf("sizeof(Foo) in a.cpp: %d\n", sizeof(Foo));
Foo().foo();
bar();
test_b();
return 0;
}

"b.cpp"

#include <stdio.h>

struct Foo {
char a[20];
void foo(){
puts("foo from b.cpp");
}
};

//void bar() { puts("bar from b.cpp"); } // error: symbol already defined

void test_b()
{
printf("sizeof(Foo) in b.cpp: %d\n", sizeof(Foo));
Foo().foo();
// bar();
}




== 2 of 2 ==
Date: Tues, Oct 22 2013 6:48 am
From: sg


Am 22.10.2013 15:20, schrieb blazb:
> Why does the linker (gcc, msvc) not fail for the example below?
>
> It complains for multiple definitions of function bar, but not for multiple definitions of function foo in class Foo.

That's because foo is defined inside a class and therefore implicitly
inline. The one definition rule makes an exception for inline functions
(as well as function templates and static data members of class templates).





==============================================================================

You received this message because you are subscribed to the Google Groups "comp.lang.c++"
group.

To post to this group, visit http://groups.google.com/group/comp.lang.c++?hl=en

To unsubscribe from this group, send email to comp.lang.c+++unsubscribe@googlegroups.com

To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.c++/subscribe?hl=en

To report abuse, send email explaining the problem to abuse@googlegroups.com

==============================================================================
Google Groups: http://groups.google.com/?hl=en