Monday, August 31, 2015

Digest for comp.lang.c++@googlegroups.com - 3 updates in 2 topics

"Chris M. Thomasson" <nospam@nospam.nospam>: Aug 31 03:03PM -0700

> > news:ms2dl3$v64$1@speranza.aioe.org:
 
> >> "Paavo Helde" wrote in message
> >> news:XnsA507EF07353Cmyfirstnameosapriee@216.166.105.131...
[...]
 
> >> were talking about vector::data().
 
> > Is casting the const away Kosher?
 
> No, it is not. Why do you ask?
 
Ummm, I totally misread the message Pavvo!
 
Sorry about that non-sense.
 
;^/
"Öö Tiib" <ootiib@hot.ee>: Aug 31 03:31PM -0700


> > You write that binary generated from stutter is longer with
> > std=c++1y compiler ... yet you choose stutter? Odd choice.
 
> I choose it in part to avoid requiring a C++ 2014 compiler.
 
That is good reason all alone if you have to support older
compilers.
 
 
> I admit the make_unique form is easier to read. I would
> like to see support for make_unique added to C++ 2011
> compilers.
 
The compiler makers may do it or not, it is their choice. C++11
itself won't change since we don't have time machines.
"Öö Tiib" <ootiib@hot.ee>: Aug 31 02:30PM -0700

On Monday, 31 August 2015 21:49:41 UTC+3, jacobnavia wrote:
 
> It DOES NOT WORK for the templates issue!
 
> Please do not try to paint me in that "troll" corner.
 
> I just have to do this idiotic job and that is punishment enough!
 
If that is true then you are behaving like that news anchor in
comedy that happened to wrong place, lost her car and cellphone
and everybody thought that she is prostitute. What she did wrong
was constantly telling that she is not prostitute, not doing
blowjobs for heroine etc. That she did instead of explaining who
she is and what problems she has and what happened to her and what
she actually wants from others. She sort of painted herself into
that prostitute corner by her own behavior.
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

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

woodbrian77@gmail.com: Aug 31 12:03PM -0700

On Monday, August 31, 2015 at 3:34:03 AM UTC-5, Öö Tiib wrote:
> > because it's small and doesn't require a C++2014 compiler.
 
> You write that binary generated from stutter is longer with
> std=c++1y compiler ... yet you choose stutter? Odd choice.
 
I choose it in part to avoid requiring a C++ 2014 compiler.
 
> Maybe I misunderstand something but it seems like you are
> making it both less readable and less efficient?
 
I admit the make_unique form is easier to read. I would
like to see support for make_unique added to C++ 2011
compilers.
 
Brian
Ebenezer Enterprises - G-d is love.
http://webEbenezer.net
jt@toerring.de (Jens Thoms Toerring): Aug 31 07:46PM

> kosher now. In practice, &vec[0] and &str[0] have always been kosher
> (albeit a bit ugly and non-intuitive - I guess that's why non-const
> vector::data() was added).
 
Yup, I think I had been looking at the option of using a vector
while still using C++98 and decided that it wouldn't be viable
(I tend to be a bit paranoid and avoid anything not guaranteed
by the standard - I don't want someone ending up with wrong
data because I used some fishy shortcuts). And then I didn't
check again if anything had changed about that with C++11, just
remembering that there was some kind of a snag.
 
Of course, there's the point that Chris Vines brings up, i.e.,
that resize() on the vector will initialize all of that data
without that being necessary. On the other had when you have
to get several MBs from a device that's typically the real
bottleneck (at least if it arrives via USB or LAN or some-
thing even slower) compared the initialization of the memory
with 0.
 
Nice to know that I've now got one more option;-)
 
Thanks and best regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
legalize+jeeves@mail.xmission.com (Richard): Aug 31 07:51PM

[Please do not mail me a copy of your followup]
 
Paavo Helde <myfirstname@osa.pri.ee> spake the secret code
 
>Since C++11 std::vector has non-const data() overload and std::string has
>the contiguous buffer guarantee.
 
Be aware that writing through the pointer returned by data() is
undefined behavior.
<http://en.cppreference.com/w/cpp/string/basic_string/data>
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
The Terminals Wiki <http://terminals.classiccmp.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
Paavo Helde <myfirstname@osa.pri.ee>: Aug 31 03:29PM -0500

legalize+jeeves@mail.xmission.com (Richard) wrote in
 
> Be aware that writing through the pointer returned by data() is
> undefined behavior.
> <http://en.cppreference.com/w/cpp/string/basic_string/data>
 
I think nobody here has proposed to use basic_string::data() (and casting
away const) for obtaining a pointer to a mutable buffer, we were talking
about vector::data().
 
But otherwise, yes it would be nice to have also a non-const version of
basic_string::data() for write access. Meanwhile I recalled another issue
with &string[0] apart of ugliness, namely it is UB when the length of the
string is zero (whereas vector::data() on a zero size vector is OK).
 
Cheers
Paavo
"Chris M. Thomasson" <nospam@nospam.nospam>: Aug 31 01:32PM -0700

> "Paavo Helde" wrote in message
> news:XnsA507EF07353Cmyfirstnameosapriee@216.166.105.131...
[...]
 
> I think nobody here has proposed to use basic_string::data() (and casting
> away const) for obtaining a pointer to a mutable buffer, we were talking
> about vector::data().
 
Is casting the const away Kosher?
Paavo Helde <myfirstname@osa.pri.ee>: Aug 31 03:34PM -0500

"Chris M. Thomasson" <nospam@nospam.nospam> wrote in
>> casting away const) for obtaining a pointer to a mutable buffer, we
>> were talking about vector::data().
 
> Is casting the const away Kosher?
 
No, it is not. Why do you ask?
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Aug 31 09:41PM +0100

On Mon, 31 Aug 2015 13:32:32 -0700
> > casting away const) for obtaining a pointer to a mutable buffer, we
> > were talking about vector::data().
 
> Is casting the const away Kosher?
 
std::vector::data() is not const for a non-const vector.
jt@toerring.de (Jens Thoms Toerring): Aug 31 08:58PM


> Be aware that writing through the pointer returned by data() is
> undefined behavior.
> <http://en.cppreference.com/w/cpp/string/basic_string/data>
 
There-in lies a certain problem: it's not uncommon that the
devices I have to interface return ASCII data for certain re-
quests (e.g., with an ascilloscope, the current timebase or
sensitivity of a channel) and binary for requests that return
lots of data (e.g. a measured waveform). And what I really got
to like about C++'s strings is that they, in contrast to C
strings, can perfectly handle binary data. So, in the best of
all worlds, I would prefer to simply use a string for every-
thing (and leave the interpretation of what they contain to
some later stage) - but, unfortunately, because of the UB you
mention, they can't be used as buffers the same way as vectors.
Of course, I could use a vector<char>, it's just that that then
has to be converted to a string in all the cases where the de-
vice did send an ASCII string. Well, life's never perfect;-)
 
Best regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
Paavo Helde <myfirstname@osa.pri.ee>: Aug 31 04:08PM -0500

jt@toerring.de (Jens Thoms Toerring) wrote in
> thing (and leave the interpretation of what they contain to
> some later stage) - but, unfortunately, because of the UB you
> mention, they can't be used as buffers the same way as vectors.
 
Yes they can - by using slightly uglier syntax &string[0] (or (string.empty
()? NULL: &string[0]) instead of string.data().
ram@zedat.fu-berlin.de (Stefan Ram): Aug 31 07:38PM

>I admit the make_unique form is easier to read. I would
>like to see support for make_unique added to C++ 2011
>compilers.
 
When passing the constructor arguments of unknown number to
make_unique, variadic templates help to implement make_unique
as a function template.
 
In C++ 2011, possibly it can be done for some numbers of
arguments with several different templates. For example, for
a single argument »x«:
 
template< class T, typename S >::std::unique_ptr< T >make_unique( S x )
{ return( ::std::unique_ptr< T >(new T( my_forward< S >( x )))); }
 
template< typename T >T && my_forward( T && x )
{ return static_cast< T&& >( x ); }.
 
(not tested).
"Öö Tiib" <ootiib@hot.ee>: Aug 31 02:24AM -0700

On Monday, 31 August 2015 11:59:22 UTC+3, Öö Tiib wrote:
> Wikipedia contains article about it:
> https://en.wikipedia.org/wiki/Bush_hid_the_facts
> Those heuristics are not a part of C++ for obvious reasons.
 
I forgot to mention that the heuristics are in 'IsTextUnicode' function
of Windows API:
https://msdn.microsoft.com/en-us/library/windows/desktop/dd318672(v=vs.85).aspx
So use it at your own risk and pay close attention to usage of 'lpiResult'
parameter of it.
legalize+jeeves@mail.xmission.com (Richard): Aug 31 07:14PM

[Please do not mail me a copy of your followup]
 
Gerhard Wolf <leawolf@gmx.de> spake the secret code
 
>std::string line = std::string(wline.begin(), wline.end());
>does not work.
 
std::string and std::wstring are just typedefs for flavors of
std::basic_string:
 
<http://en.cppreference.com/w/cpp/string>
 
All the members functions you're using are really defined on
std::basic_string.
 
There is a facility in the locale library for "narrowing" wide strings
(std::basic_string<wchar_t>) and "widening" narrow strings
(std::basic_string<char>). However, I find the API cumbersome to use
and people aren't very familiar with the details of the locale support
in the standard library so it's hard to find people who can answer
your questions.
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
The Terminals Wiki <http://terminals.classiccmp.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
David Brown <david.brown@hesbynett.no>: Aug 31 02:55PM +0200

On 31/08/15 13:49, jacobnavia wrote:
 
> The C containers library is written in C and features nice stuff. Fully
> open source (no license) available at:
 
> https://code.google.com/p/ccl/
 
Regardless of any pros or cons of the CCL and C versus the STL and C++,
would you please sort out your licensing issues. The link about claims
it is a BSD 3-clause license, but that requires copyright information
and licence information in the software. As far as I can see, there is
no such information in either the documentation or any of the files.
 
This means that the code /cannot/ be used for any purpose, except
perhaps personal evaluation - whether it be open source, closed source,
commercial or free. You need to make the licensing and copyrights clear
(or alternatively, make it entirely clear that you are donating
everything to public domain).
 
As far as I can tell, you want people to be able to freely use your code
in open and closed software - so a 3-clause BSD license is a good
choice. But it must be explicit in the code and documentation, along
with copyright notices (without which the license makes no sense) - it
is not enough to have a note on the code.google.com project page.
 
 
One day I hope to get the time to look at CCL properly - but
unfortunately, that will not be today.
Ian Collins <ian-news@hotmail.com>: Sep 01 07:14AM +1200

jacobnavia wrote:
>> have been significanly easier in C++ (mainly, although not solely,
>> because in C++ you can skip all those annoying mallocs and frees.)
 
> In C you can do it too if you use the GC.
 
Heap memory isn't the only resource that needs to be managed....
 
--
Ian Collins
legalize+jeeves@mail.xmission.com (Richard): Aug 31 07:03PM

[Please do not mail me a copy of your followup]
 
Laszlo Lebrun <lazlo.lebrun@googlemail.com> spake the secret code
>outputs the result to an internal windows virtual serial port using a
>given protocol. (So an existing program from which I have no code,
>believes to read original serial data from COMxx)
 
You can use boost.asio to read/write data from/to serial ports:
<http://www.boost.org/doc/libs/1_59_0/doc/html/boost_asio/overview/serial_ports.html>
 
>How tricky is that?
 
>Does a library exist to simulate a serial COM port?
>Is that accessible to a technically oriented noob within a few weeks?
 
So if I understand you correctly, you want to read data from a
physical serial port, intercept and/or manipulate it in some way, and
make that modified data stream available through a virtual serial port
to some other application. The other application is connected to the
virtual serial port as if it were connected to the original hardware
serial port.
 
How you provide a serial port to an operating system is beyond the
scope of this newsgroup, but this stack overflow thread might help for
Windows:
<http://stackoverflow.com/questions/1605721/faking-an-rs232-serial-port>
 
Another option is to simply stick a small hardware device in the
cabling. An arduino could easily process the serial port data on one
port and write the data out on another port. Again, this is beyond
the scope of this newsgroup.
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
The Terminals Wiki <http://terminals.classiccmp.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
Ed Anson <EdAnson@comcast.net>: Aug 30 07:58PM -0400

On 8/29/15 4:18 PM, Ian Collins wrote:
> 1) Stick with the old compiler. Sometimes the effort required to work
> with new tools is too great.
 
I'll second that. I have been working with a legacy code base that was
developed around 2000. The compiler is similarly non-compliant. My
organization's solution was to VERY carefully preserve the compiler that
was originally used and to continue using it.
 
Although this approach has the down side of preventing use of modern
tools, it also prevents the massive expense of refactoring -- and
re-testing -- the entire code base. For a legacy product that is no
longer being developed (bug fixes only), that is the most practical
decision.
 
OTOH if the product is still being actively developed, that is another
matter entirely. In that case, it may be well worth the expense to adapt
the code to work with current tools. You might even be surprised at how
many latent bugs are exposed in the process. IME the best practice is to
incrementally refactor code every time it is changed. That helps keep
the code base in good shape.
Juha Nieminen <nospam@thanks.invalid>: Aug 31 07:37AM

> Of course this forum is useless for asking this types of questions. I
> know now that better.
 
You have to maintain incorrectly-made code that just happened to compile on a
non-standard compiler, then you ask here what to do with a very vague question
without actual concrete examples, and then you get all butthurt when you get
a generic answer, and get a temper tantrum worthy of a 5-year-old.
 
Yes, that's the correct way of getting answers and solving your problems.
Stomp the floor and whine until somebody does what you want.
 
--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Aug 31 01:59PM +0100

On Mon, 31 Aug 2015 07:37:39 +0000 (UTC)
> tantrum worthy of a 5-year-old.
 
> Yes, that's the correct way of getting answers and solving your
> problems. Stomp the floor and whine until somebody does what you want.
 
Bearing in mind the fact that the original question was so general as to
be meaningless and unanswerable, and given the OP's past contributions
to this newsgroup, I think it improbable that he is "trying to maintain
a huge C++ database application with templates all around" as stated.
That task would surely be given to someone who is actually a C++
programmer of reasonable experience.
 
It seems much more probable that the OP is pursuing his ludicrous "C
macros are as good as or better than C++ templates" meme with a bit of
troll fodder.
 
Chris
jacobnavia <jacob@jacob.remcomp.fr>: Aug 31 05:34PM +0200

Le 31/08/2015 14:59, Chris Vine a écrit :
> It seems much more probable that the OP is pursuing his ludicrous "C
> macros are as good as or better than C++ templates" meme with a bit of
> troll fodder.
 
Yes, of course.
 
Look, as many others I am forced to work through this monster
applications where C++ heads leave for the maintenance team or somebody
else to clean up after them.
 
I am just trying to make it compile clean. I started to do what was
proposed here: to add in each file the declarations where needed.
 
But then, the next problem started:
 
friend declarations can't have default arguments. Decision of the C++
standards committee of 1999.
 
In 2010 that code still compiled OK.
 
IN 2015 it doesn't. That was fixed in gcc-something.
 
In principle the solution is simple: Eliminate the default arguments and
make the all explicit.
 
I am almost through that. Then I will go on with the next mess.
 
jacob
 
P.S. Yes, I do not like C++. For obvious reasons. That makes me a troll?
 
Should I abstain from asking questions here?
Melzzzzz <mel@zzzzz.com>: Aug 31 06:14PM +0200

On Mon, 31 Aug 2015 17:34:43 +0200
 
> IN 2015 it doesn't. That was fixed in gcc-something.
 
> In principle the solution is simple: Eliminate the default arguments
> and make the all explicit.
 
What's wrong with adding declaration?
 
#include <iostream>
 
void f(int = 6);
struct A{
friend void f(int);
};
 
int main()
{
f();
}
 
void f(int a)
{
std::cout<<a<<'\n';
}
 
> I am almost through that. Then I will go on with the next mess.
 
Heh.
 
 
> jacob
 
> P.S. Yes, I do not like C++. For obvious reasons. That makes me a
> troll?
 
You do not like C++ simply because you like C too much ;p
 
 
> Should I abstain from asking questions here?
 
No.
Melzzzzz <mel@zzzzz.com>: Aug 31 06:28PM +0200

On Mon, 31 Aug 2015 18:14:35 +0200
 
> > IN 2015 it doesn't. That was fixed in gcc-something.
 
> > In principle the solution is simple: Eliminate the default arguments
> > and make the all explicit.
 
Also have you tried -fpermissive?
jacobnavia <jacob@jacob.remcomp.fr>: Aug 31 06:54PM +0200

Le 31/08/2015 18:28, Melzzzzz a écrit :
> Also have you tried -fpermissive?
 
Yes, of course that works. But doing that kind of stuff exposes me to
the QA manager that surely will look at that with a bad eye
 
:-(
bartekltg@gmail.com: Aug 31 11:12AM -0700

W dniu poniedziałek, 31 sierpnia 2015 18:54:58 UTC+2 użytkownik jacobnavia napisał:
 
> Yes, of course that works. But doing that kind of stuff exposes me to
> the QA manager that surely will look at that with a bad eye
 
> :-(
 
"Dear mr manager, we fucked up 5 years ago and wrote a code that is
incompatible with the standard, but it works on our compiler.
Now these saboteur from gnu fix... I mean change it and we either
spend two day by typing "typename" in our code or we can compile
it with -fpermissive. I want to emphasize that our code will
be not less standard compatible than for the last 5 years."
 
;-)
 
This is a businesses decision. Put some effort to clean it
or go around the problem.
 
bartekltg
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Aug 31 07:32PM +0100

On Mon, 31 Aug 2015 18:54:38 +0200
 
> Yes, of course that works. But doing that kind of stuff exposes me to
> the QA manager that surely will look at that with a bad eye
 
> :-(
 
Your original complaint was about an issue with templates, not with
friend functions. If -fpermissive solves the template issue as well
then I would guess it was a simple dependent name look-up issue in a
base class method called from a derived class method. gcc got more
strict about that a few years ago when moving to support two phase
look-up in conformity with the standard, but retained the old behaviour
for defective code with the -fpermissive flag.
 
If you had originally posted a more informative post with some code and
sample error messages instead of complaining about "getting hundreds of
undefined references in those templates" with the question "How can I
revert to the good old times?", and it was a name look-up issue, people
would have been able to help you and you would have been told to use
the -fpermissive flag to revert to the good old times.
 
The fact that you knew about this all along ("of course that works")
seems to prove the point that in your original posting you were not
asking a genuine question but just having a good rant.
 
But if I am wrong about that and you still want an answer about your
template problems (and being told "how can I revert to the good old
times" is not after all enough), you can solve the issue
without -fpermissive by disambiguating the dependent name look-up,
either with a type qualifier - so if B is the template base class and
f() is the method name, by calling B::f() explicitly in your derived
class method - or by using the this keyword by calling this->f(). If
the problem is with type names not identifier names, you might need more
liberal use of the 'typename' keyword.
 
If that doesn't work, the template problems stem from something else and
you are seeking genuine help, post something more informative.
 
Chris
jacobnavia <jacob@jacob.remcomp.fr>: Aug 31 08:49PM +0200

Le 31/08/2015 20:32, Chris Vine a écrit :
> The fact that you knew about this all along ("of course that works")
> seems to prove the point that in your original posting you were not
> asking a genuine question but just having a good rant.
 
No!
 
It works for the friend declaration in a class issue.
 
It DOES NOT WORK for the templates issue!
 
Please do not try to paint me in that "troll" corner.
 
I just have to do this idiotic job and that is punishment enough!
 
Thanks
 
jacob
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

Fwd: : 中華民國建國一百年主題曲

重温旧梦!

Sent from my iPad

Begin forwarded message:

From: Dolores Kuo <doloresmkuo@gmail.com>
Date: August 31, 2015 at 3:03:41 PM CDT
To: Jensie Tou <pandjtou@aol.com>, Nancy Chao <nancyhychao@yahoo.com>,  Chris Wang <chriswang_95051@yahoo.com>, "chasjhan@yahoo.com" <chasjhan@yahoo.com>,  Tina Soong <tsoongtotherim@aol.com>
Subject: Fwd: : 中華民國建國一百年主題曲



---------- Forwarded message ----------
From: Charlotte Tao <charlottetao1@gmail.com>
Date: Monday, August 31, 2015
Subject: Fwd: : 中華民國建國一百年主題曲
To:




Sent from my iPad


From:

中華民國建國一百年主題曲
這段影片,因為版權問題,在Youtube消失了三年了,今晚突然又讓我找到了,看了一次,依然讓我感動,與大家分享:
《我們的一百年》16分鐘完整版【高畫質HD版】





--
Sent from My iPad

Fwd: 轉寄: 转发:太爽了,没删之前赶快看!



Sent from my iPad

Begin forwarded message:

From: Dolores Kuo <doloresmkuo@gmail.com>
Date: August 31, 2015 at 6:08:05 AM CDT
To: Nancy Chao <nancyhychao@yahoo.com>, "chasjhan@yahoo.com" <chasjhan@yahoo.com>,  Charlotte Tao <charlottetao1@gmail.com>, "ronny_lin@hotmail.com" <ronny_lin@hotmail.com>,  Tina Soong <tsoongtotherim@aol.com>
Subject: Fwd: 轉寄: 转发:太爽了,没删之前赶快看!



---------- Forwarded message ----------
From: Chris <chriswang_95051@yahoo.com>
Date: Sunday, August 30, 2015
Subject: Fwd: 轉寄: 转发:太爽了,没删之前赶快看!
To:





--
Sent from My iPad

Digest for comp.lang.c++@googlegroups.com - 25 updates in 3 topics

JiiPee <no@notvalid.com>: Aug 31 12:59AM +0100

On 31/08/2015 00:25, Jens Thoms Toerring wrote:
> vector). I'll have to see how I can use this newly acquired piece
> of knowledge;-)
> Regards, Jens
"
 
It would be different if one would be able to write directly
to the vectors memory area and change it's size afterwards,
but that's not allowed.
 
"
 
But dont you still have the problem that the vector will allocate
possible two times more memory than you need because of the capacity?
yes you can write to its memory I think, but you cannot really manage
yourself the amount of memory the vector allocates, can you?
bartekltg <bartek@gmail.com>: Aug 31 02:21AM +0200

On 31.08.2015 01:59, JiiPee wrote:
 
> "
 
> But dont you still have the problem that the vector will allocate
> possible two times more memory than you need because of the capacity?
 
I have checked it and it is not that bad.
If you insert data by series of 'push_back()' it may be
two times too much. But if you resize to necessary size,
or reserve enough space, vector use only so much memory
(plus allocator data + alignment Bo Persson was talking,
about). At least in a simple test in gcc 4.9.2.
 
bartekltg
JiiPee <no@notvalid.com>: Aug 31 02:04AM +0100

On 31/08/2015 01:21, bartekltg wrote:
> or reserve enough space, vector use only so much memory
> (plus allocator data + alignment Bo Persson was talking,
> about). At least in a simple test in gcc 4.9.2.
 
oh, did not consider that. So without pushbacks it should allocate about
the requested memory. But obviously one would like be sure that this is
how the vector always works. The resize documentation does not mention
anything about it really.
Paavo Helde <myfirstname@osa.pri.ee>: Aug 30 11:25PM -0500

> the requested memory. But obviously one would like be sure that this is
> how the vector always works. The resize documentation does not mention
> anything about it really.
 
Oh come on guys, the compiler/STL writers are worried about the performance
at least as much as you are (plus they actually know what they are doing).
They will not go and preallocate reams of extra memory just because of fun
or something.
 
Cheers
Paavo
Paavo Helde <myfirstname@osa.pri.ee>: Aug 30 11:55PM -0500

jt@toerring.de (Jens Thoms Toerring) wrote in
> pointer only? Could be that I'm too squeamish and it's above
> the board to do it that way. If it is it would make some
> things quite a bit simpler;-)
 
Since C++11 std::vector has non-const data() overload and std::string has
the contiguous buffer guarantee. So both vector::data() and &str[0] are
kosher now. In practice, &vec[0] and &str[0] have always been kosher
(albeit a bit ugly and non-intuitive - I guess that's why non-const
vector::data() was added).
 
Cheers
Paavo
woodbrian77@gmail.com: Aug 30 10:38PM -0700

On Sunday, August 30, 2015 at 5:58:51 PM UTC-5, Öö Tiib wrote:
 
> I 'reset' smart pointer for same reasons why I 'clear' a container.
> It has to be empty by program logic and so I 'reset' or 'clear' it.
> I may need 'new' for some rare reasons like for covariance.
 
This line
 
auto request=::std::make_unique<cmw_request>(localbuf);
 
results in a text segment that's 71 bytes bigger than this line
 
auto request=::std::unique_ptr<cmw_request>(new cmw_request(localbuf));
 
using gcc 5.1.1 on Linux. I've taken that line from this
program - http://webEbenezer.net/misc/cmwAmbassador.cc
 
I compile the code with std=c++1y for the version with
make_unique. For the other version I compile it with
std=c++11. If I compile the version with new using
std=c++1y, it's 88 bytes bigger than the version with
make_unique. The version that uses new is attractive
because it's small and doesn't require a C++2014 compiler.
 
 
Brian
Ebenezer Enterprises - In G-d we trust.
http://breitbart.com
"Öö Tiib" <ootiib@hot.ee>: Aug 31 01:33AM -0700

> std=c++1y, it's 88 bytes bigger than the version with
> make_unique. The version that uses new is attractive
> because it's small and doesn't require a C++2014 compiler.
 
You write that binary generated from stutter is longer with
std=c++1y compiler ... yet you choose stutter? Odd choice.
Maybe I misunderstand something but it seems like you are
making it both less readable and less efficient?
As for std=c++11 how you know that the difference with
std=c++1y is anyhow related to that 'request' variable?
 
In general if there is actually some quality of implementation
issue and it matters and fix reduces readability (like stutter
in your example) then I expect a comment in code that
documents the reason, (but I can't see one in your example).
 
My strong push towards readability is because I work with
teams on code that has to stay maintainable years later.
Other people may of course do whatever they want with
their code.
bartekltg <bartekltg@gmail.com>: Aug 29 06:10PM +0200

On 29.08.2015 14:15, JiiPee wrote:
>> resevre(n) allocata 'at least n'. shrint_to_fit is only a sugestion.
 
> Ok so if we need a vector which behaves differently than std::vector.
> I think std::vector should have an option to set capacity = size.
 
And we have since c++11. It is shrink_to_fit I was talking about.
but i may not work:
"
void shrink_to_fit();
14 Remarks: shrink_to_fit is a non-binding request to reduce capacity()
to size(). [ Note: The
request is non-binding to allow latitude for implementation-specific
optimizations. — end note ]
"
 
> A bit strange to create my own vector class just because the std version
> allocates too much memory. the capacity functionality
> should be maybe optional? why is it not?
 
Because vectro should be ready for multiple 'push_back'.
If you always keep only enough memory,
vector <double> tab;
for (int i=0;i<N;++)
tab.pushback(sin(0.1*i));
will be quadratic.
 
A standard solution for that is to allocate "too much" memory.
Then it is linear.
 
 
vector is a very good universal container. But sometimes
a feature, needed 99% of times, is not optimal for you.
 
> but can't you use std::valarray for that? it does not have capacity
 
I can. It even may be better for compiler to optimize the code.
 
 
 
bartekltg
bartekltg <bartekltg@gmail.com>: Aug 29 05:44PM +0200

On 29.08.2015 14:15, JiiPee wrote:
>> resevre(n) allocata 'at least n'. shrint_to_fit is only a sugestion.
 
> Ok so if we need a vector which behaves differently than std::vector.
> I think std::vector should have an option to set capacity = size.
 
And we have since c++11. It is shrink_to_fit I was talking about.
but i may not work:
"
void shrink_to_fit();
14 Remarks: shrink_to_fit is a non-binding request to reduce capacity()
to size(). [ Note: The
request is non-binding to allow latitude for implementation-specific
optimizations. — end note ]
"
 
> A bit strange to create my own vector class just because the std version
> allocates too much memory. the capacity functionality
> should be maybe optional? why is it not?
 
Because vectro should be ready for multiple 'push_back'.
If you always keep only enough memory,
vector <double> tab;
for (int i=0;i<N;++)
tab.pushback(sin(0.1*i));
will be quadratic.
 
A standard solution for that is to allocate "too much" memory.
Then it is linear.
 
 
vector is a very good universal container. But sometimes
a feature, needed 99% of times, is not optimal for you.
 
> but can't you use std::valarray for that? it does not have capacity
 
I can. It even may be better for compiler to optimize the code.
 
 
 
bartekltg
bartekltg <bartekltg@gmail.com>: Aug 29 07:46PM +0200

Somebody see this post? This is a third try.
 
On 29.08.2015 14:15, JiiPee wrote:
>> resevre(n) allocata 'at least n'. shrint_to_fit is only a sugestion.
 
> Ok so if we need a vector which behaves differently than std::vector.
> I think std::vector should have an option to set capacity = size.
 
And we have since c++11. It is shrink_to_fit I was talking about.
but i may not work:
"
void shrink_to_fit();
14 Remarks: shrink_to_fit is a non-binding request to reduce capacity()
to size(). [ Note: The
request is non-binding to allow latitude for implementation-specific
optimizations. — end note ]
"
 
> A bit strange to create my own vector class just because the std version
> allocates too much memory. the capacity functionality
> should be maybe optional? why is it not?
 
Because vector should be ready for multiple 'push_back'.
If you always keep only enough memory,
vector <double> tab;
for (int i=0;i<N;++)
tab.pushback(sin(0.1*i));
will be quadratic.
 
A standard solution for that is to allocate "too much" memory.
Then it is linear.
 
 
vector is a very good universal container. But sometimes
a feature, needed 99% of times, is not optimal for you.
 
> but can't you use std::valarray for that? it does not have capacity
 
I can. It even may be better for compiler to optimize the code.
 
 
 
bartekltg
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Aug 31 01:13PM +0100

On Mon, 31 Aug 2015 02:04:05 +0100
JiiPee <no@notvalid.com> wrote:
[snip]
> about the requested memory. But obviously one would like be sure that
> this is how the vector always works. The resize documentation does
> not mention anything about it really.
 
std::vector::reserve() must allocate as much as requested (or throw)
and can allocate more, but in practice it will do what you ask it
subject to the requirements of alignment. A reasonable implementation
is not going to do something stupid gratuitously.
 
Of course, in the case that your most recent posts have been concerned
with - using std::vector as a buffer for some other function such as
read() to read into - you should really use std::vector::resize()
rather than std::vector::reserve() so that the vector is correctly
sized (std::vector::data() returns "a pointer such that [data(), data()
+ size()) is a valid range"), but that has the disadvantage that it
acts like calloc(), namely that for built-in types it default-inserts
elements into its memory with value initialization to 0.
 
If avoiding any unnecessary zeroing operations on built-in types when
constructing the buffer is wanted, then if all you want is a buffer
where the size is not known at compile time but is known at run time
(or you want the buffer to have a longer lifetime than block scope) it
is perfectly fine to use std::unique_ptr with the new[] expression; and
if you know the size of the buffer at compile time, you should use a
C-style array or std::array where all you want is a plain buffer with
block scope.
 
On your more general question "is new-allocation needed anymore", it is
also needed for placement new.
 
Chris
Juha Nieminen <nospam@thanks.invalid>: Aug 31 07:14AM

> I think a better way of approaching C++ is to use some
> of the standard library facilities. For example, use a
> vector rather than an array.
 
Was he talking about static arrays or dynamic arrays (ie. those you
create with new or malloc)?
 
I wouldn't be surprised if the context was the question of whether
it's better to use "raw" arrays (ie. allocated with new and through
raw pointers) or a standard data container.
 
--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
Juha Nieminen <nospam@thanks.invalid>: Aug 31 07:18AM

> You can't have it both ways.
 
Of course you can. Why is it so hard to accept that one language may be
faster in some things and another language in another thing?
 
C++ is faster in generic code (qsort() vs. std::sort() being the
quintessential example). And we don't even need some highly-twinkered
artificial constructed example for this. The code for std::sort() doesn't
need to resort to low-level trickery to achieve this speed.
 
Those benchmarks where C is like 2% faster than C++ are almost invariably
really artificial and, essentially, horrible low-level code that no sane
person would use in an actual program.
 
--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
Juha Nieminen <nospam@thanks.invalid>: Aug 31 07:28AM

> No. My C compiler system features garbage collection. Using Boehm's
> software, you do not need to do anything "manually".
 
How fitting, considering the title of the thread...
 
Well, you can use your GC'd C variant if you want. I'll keep using C++,
which is much simpler, cleaner and easier to use (and in many cases
more efficient.)
 
--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
jacobnavia <jacob@jacob.remcomp.fr>: Aug 31 11:17AM +0200

Le 31/08/2015 09:18, Juha Nieminen a écrit :
>> You can't have it both ways.
 
> Of course you can. Why is it so hard to accept that one language may be
> faster in some things and another language in another thing?
 
 
Then why is it so difficult for you to accept that C is faster?
 
 
> C++ is faster in generic code (qsort() vs. std::sort() being the
> quintessential example).
 
This is because the C compilers haven't been taught to do the same that
they do for C++.
 
In principle a C compiler could also look into the called function of
qsort and inline it if needed!
 
Or you could modify the sognature of qsort so that you could pass it an
inline function and expect it to expand the qsort algorithm specialized
for this data type!
 
Why this isn't done?
 
 
And we don't even need some highly-twinkered
> artificial constructed example for this. The code for std::sort() doesn't
> need to resort to low-level trickery to achieve this speed.
 
???
 
You leave the trickery to the compiler.
 
> Those benchmarks where C is like 2% faster than C++ are almost invariably
> really artificial and, essentially, horrible low-level code that no sane
> person would use in an actual program.
 
 
No. They are written by people who care about performance.
jacobnavia <jacob@jacob.remcomp.fr>: Aug 31 11:19AM +0200

Le 31/08/2015 09:28, Juha Nieminen a écrit :
 
> How fitting, considering the title of the thread...
 
> Well, you can use your GC'd C variant if you want. I'll keep using C++,
> which is much simpler,
 
C++simpler than C.
 
Of course!
 
How did I miss that?
 
:-)
 
> cleaner
 
Wow, C is "dirty" did you get that?
 
 
and easier to use
 
Sure
 
(and in many cases more efficient.)
 
Yes. You win.
 
C++ is SIMPLER than C. OK
Ian Collins <ian-news@hotmail.com>: Aug 31 09:44PM +1200

jacobnavia wrote:
> they do for C++.
 
> In principle a C compiler could also look into the called function of
> qsort and inline it if needed!
 
How do you propose doing that for every C function where C++ would use a
function template that has a void* or a function pointer as its
parameter(s)?
 
--
Ian Collins
jacobnavia <jacob@jacob.remcomp.fr>: Aug 31 11:53AM +0200

Le 31/08/2015 11:44, Ian Collins a écrit :
> How do you propose doing that for every C function where C++ would use a
> function template that has a void* or a function pointer as its
> parameter(s)?
 
If you have a function that accepts a function parameter and that
parameter is an inline function, it is possible for the compiler, if the
definition of the inline function is available (as it has to be) to
expand the calls into that fnction and merge the resulting code into the
bigger function code.
 
This is just making the "inline" keyword more sophisticated, that is all.
 
But the C committee is not going to go into that direction. So, C
remains "slower".
 
Many function templates can also be done with C macros, but surely not
all of them.
Juha Nieminen <nospam@thanks.invalid>: Aug 31 11:40AM

> C++ is SIMPLER than C. OK
 
It indeed is.
 
int main(int argc, char* argv[])
{
std::vector<std::string> params(argv, argv + argc);
std::sort(params.begin(), params.end());
std::string str;
for(auto& p: params) str += p;
std::cout << str << "\n";
}
 
That's significantly simpler than what you have to do with C.
 
(And no, I'm not talking about the *output* of the program. You can certainly
make the program print the same thing with simpler code than the above.
That's not the point. The point is that those operations are much more
complicated to do in C than in C++. This example is just a demonstration
of their use; the actual printed output is not the important point.)
 
C is actually a very frustrating language. An acquaintance of mine went
through a C course recently, and constantly asked for my help. It was
really frustrating to have to deal with all those mallocs and frees
(especially when reading strings of indeterminate length from a file
into a complex data structure). Every single task he had to do would
have been significanly easier in C++ (mainly, although not solely,
because in C++ you can skip all those annoying mallocs and frees.)
 
--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
jacobnavia <jacob@jacob.remcomp.fr>: Aug 31 01:49PM +0200

Le 31/08/2015 13:40, Juha Nieminen a écrit :
> std::cout << str << "\n";
> }
 
> That's significantly simpler than what you have to do with C.
 
I posted this last week:
 
Using the CCL (C containers library) we have: (from memory)
 
#include <containers.h>
 
int main(void)
{
strCollection *myData =
strCollection.CreateFromFile("mydata.txt");
strCollection.Sort(myData);
strCollection.WriteToFile(myData,"mySortedData.txt");
return 0;
}
 
The C containers library is written in C and features nice stuff. Fully
open source (no license) available at:
 
https://code.google.com/p/ccl/
 
In C you czan do exactly the same.
 
> That's not the point. The point is that those operations are much more
> complicated to do in C than in C++. This example is just a demonstration
> of their use; the actual printed output is not the important point.)
 
If you use containers in C you have the same abstraction level.
 
> into a complex data structure). Every single task he had to do would
> have been significanly easier in C++ (mainly, although not solely,
> because in C++ you can skip all those annoying mallocs and frees.)
 
 
In C you can do it too if you use the GC.
Gerhard Wolf <leawolf@gmx.de>: Aug 31 08:34AM +0200

> Use std::wstring and std::wfstream instead of std::string and
> std::fstream and imbue your std::wfstream with the encoding used in the
 
Thanks. Using std::w* was half the battle because
it seems all the std::string functions (find, subst...),
std::setw, ..setfill have no std::w* counterpart or im a wrong?
So i have to convert to std::string? but how?
 
 
std::string line = std::string(wline.begin(), wline.end());
does not work.
Gerhard Wolf <leawolf@gmx.de>: Aug 31 08:35AM +0200

> Use std::wstring and std::wfstream instead of std::string and
> std::fstream and imbue your std::wfstream with the encoding used in the
> input file.
 
 
Thanks. Using std::w* was half the battle because
it seems all the std::string functions (find, subst...),
std::setw, ..setfill have no std::w* counterpart!?
So i have to convert to std::string? but how?
 
 
std::string line = std::string(wline.begin(), wline.end());
does not work.
Gerhard Wolf <leawolf@gmx.de>: Aug 31 08:47AM +0200

Ok i created a 3rd and a 4th File. It contains both 'ü' variants in HEX:
61 FC 62 3C BC 62
 
and a File4 (FC-3CBC) flipped:
61 3C BC 62 FC 62
 
Windows Notepad (Sublime Text) opens:
File1 displaying aüb (61 FC 62)
File2 " aüb (61 C3 BC 62)
File3 " aüb<¼b (61 FC 62 3C BC 62)
File4 " a<¼büb (61 3C BC 62 FC 62)
 
it seems these or all Win Applications (or MS libs) seems handle
both variants correct if not mixed otherwise basic 8 bit character set
is used.
But that doesn't help solving my problem.
Ralf Goertz <me@myprovider.invalid>: Aug 31 09:59AM +0200

Am Mon, 31 Aug 2015 08:34:19 +0200
> it seems all the std::string functions (find, subst...),
> std::setw, ..setfill have no std::w* counterpart or im a wrong?
> So i have to convert to std::string? but how?
 
No, you don't have to convert to std::string (and it wouldn't generally
solve your problem as you can't fit *each* utf-8 encoded character into
8bit simultaneously). And yes, you can use find(), subst() etc. on
wstring since it is merely a „typedef basic_string<wchar_t> wstring;"
and these functions are defined with basic_string, eg.:
 
http://www.cplusplus.com/reference/string/basic_string/find/
 
What you have to keep in mind is that you have to use the „L" specifier
when using literals:
 
std::wstring ws=L"Hello World";
 
Ralf
"Öö Tiib" <ootiib@hot.ee>: Aug 31 01:59AM -0700

On Monday, 31 August 2015 09:47:47 UTC+3, Gerhard Wolf wrote:
> both variants correct if not mixed otherwise basic 8 bit character set
> is used.
> But that doesn't help solving my problem.
 
MS Notepad is using pile of heuristics to detect the encoding of text
in *.txt file. Sometimes the heuristics fail in notable way so even
Wikipedia contains article about it:
https://en.wikipedia.org/wiki/Bush_hid_the_facts
Those heuristics are not a part of C++ for obvious reasons.
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

Sunday, August 30, 2015

Digest for comp.lang.c++@googlegroups.com - 8 updates in 3 topics

Paavo Helde <myfirstname@osa.pri.ee>: Aug 30 04:36PM -0500

jt@toerring.de (Jens Thoms Toerring) wrote in
> It would be different if one would be able to write directly
> to the vectors memory area and change it's size afterwards,
> but that's not allowed.
 
What do you mean? What's wrong with using a properly resized std::vector or
std::string buffer for reading a file handle?
jt@toerring.de (Jens Thoms Toerring): Aug 30 10:28PM

> > but that's not allowed.
 
> What do you mean? What's wrong with using a properly resized std::vector or
> std::string buffer for reading a file handle?
 
Chances are I'm missing something, but the only way to get
at the underlying pointer to the vector's (or string's) data
is the data() method (and for strings there-s also c_str())
- and that just returns a const pointer, i.e. something I
can't pass to read(). Ok, one can use '&vec[0]' to obtain
that address also, but I hadn't considered to use that
address for writing to the arrays or strings memory as some-
thing kosher - but if it is why does data() return a const
pointer only? Could be that I'm too squeamish and it's above
the board to do it that way. If it is it would make some
things quite a bit simpler;-)
 
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
"Öö Tiib" <ootiib@hot.ee>: Aug 30 03:58PM -0700

On Sunday, 30 August 2015 17:34:49 UTC+3, JiiPee wrote:
> > instead of using containers.
 
> yes, and using possible delete as well (or if smar pointers, then
> reset). so total management
 
I do not know why we need 'delete'. I haven't had 'delete' for more
than decade in my own code. There are too large variety of well-tested
stock smart pointers available.
 
I 'reset' smart pointer for same reasons why I 'clear' a container.
It has to be empty by program logic and so I 'reset' or 'clear' it.
I may need 'new' for some rare reasons like for covariance.
jt@toerring.de (Jens Thoms Toerring): Aug 30 11:25PM

> returns a pointer to const value_type. Otherwise, it returns
> a pointer to value_type.
 
> (Disclaimer: I have not tried this, just read it from docs.)
 
Thanks! Took another look and found that the data() method for
vectors does indeed has a pointer to non-const version, while
strings don't (and you usually use character arrays as "byte"
arrays when using read() and friends). So I had overlooked that
with a vector more is allowed than with strings and assumed that
if strings don't do it also vectors won't (and then it seemed to
be a bit like taking too many liberties with the innards of a
vector). I'll have to see how I can use this newly acquired piece
of knowledge;-)
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
ram@zedat.fu-berlin.de (Stefan Ram): Aug 30 10:52PM

>at the underlying pointer to the vector's (or string's) data
>is the data() method (and for strings there-s also c_str())
>- and that just returns a const pointer, i.e. something I
 
(You must mean a »pointer to const«, not a »const pointer«.)
 
There are two entries in ::std::vector.
 
value_type* data() noexcept; and
const value_type* data() const noexcept;
 
. If the ::std::vector object is const-qualified, the call
returns a pointer to const value_type. Otherwise, it returns
a pointer to value_type.
 
(Disclaimer: I have not tried this, just read it from docs.)
David Brown <david.brown@hesbynett.no>: Aug 31 12:28AM +0200

On 30/08/15 23:21, Prroffessorr Fir Kenobi wrote:
>>> view, this kode above on my old C2D executes 7.6 s and yeilds to
>>> 2.178154
>> Looks closer to 2 than e....
 
That's a typo. With 100000000 iterations the answer is about 2.718359.
With more iterations, it appears to get closer to e - but converges
extremely slowly.
 
I haven't done the maths to work out the answer correctly, but I can't
say it would shock me to see the answer being e.
 
 
 
> where is that code? (changing div to mul by inverse improves quite a
> lot 7.6 -> 5.6 or alike,, but really wonder if some better than clib
> rand cannot be found..
 
Use -ffast-math, which lets the compiler do optimisations like that
automatically. And making file-local functions (and variables, though
there are none here) "static" can sometimes be of significant help in
optimising, as well as being good programming practice.
 
 
> are all this various platform rands() implement the same algorithm?
 
There are vast numbers of pseudo-random number generating algorithms. I
have no idea which one your code will be using from the C library on
your system. But it won't take much googling to find some. The quality
(which can be measured in many different ways) varies - you might find
some algorithms that look good, and give a good long-term average
pattern, yet fail to give anything close to e on this test.
bartekltg <bartek@gmail.com>: Aug 31 12:44AM +0200

On 30.08.2015 23:13, Johann Klammer wrote:
 
>> this is anyway interesting form the optimistation points of view,
>> this kode above on my old C2D executes 7.6 s and yeilds to 2.178154
> Looks closer to 2 than e....
 
It is e. Fir just doesn't care and smash keyboard without looking;-)
 
Lets n(x) be an expected value of times one need to draw
a random number idd U[0..1] to gat sum smaller than x.
We are looking for n(1).
 
We draw a number p. If p>=x we are done. In other case
we need another n(x-p) draws.
 
n(x) = 1 + \int_0^x n(x-p) dp
 
I'm sure there is a methodical way to solve the equation,
but we can guess n(x) = exp(x). Ant it works.
1+\int_0^x exp(x-p) dp = 1 - exp(x-p)|_0^x = 1-(exp(0)-exp(x))=exp(x)
 
n(1) = e.
 
 
>> probabilistic properties and faster execution..
 
>> can someone provide such routine?
 
> take the code for rand and the functions it calls from the c library and inline them in this file.
 
I'm pretty sure a decent compiler do it for us.
 
 
A version with default_random_engine (propably x = x * 48271 %
2147483647) from <random> without any trick, is only a bit slower
 
int trial2() {
static random_device rd;
static default_random_engine gen(rd());
uniform_real_distribution<double> dist(0.0,1.0);
int count = 0;
double sum = 0;
while (sum <= 1.0) {
sum += dist(gen);
count++;
}
return count;
}
 
double monteCarlo2(int n) {
int i, total = 0;
for (i = 0; i < n; i++) {
total += trial2();
}
return total / (double) n;
}
 
 
c like rand 2.718359
5.64892s
c++11 <random> 2.718232
5.73054s
c like rand 2.718111
5.67173s
c++11 <random> 2.718149
5.73041s
c like rand 2.718318
5.67199s
c++11 <random> 2.718329
5.73014s
 
And mt19937, a real pseudorandom number generator, not a toy,
get results below 8seconds.
 
bartekltg
bartekltg <bartek@gmail.com>: Aug 31 12:50AM +0200

On 31.08.2015 00:28, David Brown wrote:
 
> That's a typo. With 100000000 iterations the answer is about 2.718359.
> With more iterations, it appears to get closer to e - but converges
> extremely slowly.
 
Monte Carlo always is extremely slow. It converges like 1/sqrt(n),
so we get next significant digit after 100 times more work.
 
bartekltg
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.