Tuesday, February 27, 2018

Digest for comp.lang.c++@googlegroups.com - 10 updates in 4 topics

"James R. Kuyper" <jameskuyper@verizon.net>: Feb 27 08:30AM -0500

On 02/22/2018 07:48 PM, Egor wrote:
>> I thought C++11 introduced sleep_for(). Why not use the standard function?
> OP posted the question to both comp.lang.c and comp.lang.c++, so I
> provided a C-oriented answer.
 
A C-oriented answer using C2011 could use thrd_sleep()
Keith Thompson <kst-u@mib.org>: Feb 27 09:07AM -0800

>> OP posted the question to both comp.lang.c and comp.lang.c++, so I
>> provided a C-oriented answer.
 
> A C-oriented answer using C2011 could use thrd_sleep()
 
It could, but support for the C11 <threads.h> is still uncommon.
 
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Real Troll <Real.Troll@Trolls.com>: Feb 27 06:07PM -0400

On 27/02/2018 13:30, James R. Kuyper wrote:
>> OP posted the question to both comp.lang.c and comp.lang.c++, so I
>> provided a C-oriented answer.
 
> A C-oriented answer using C2011 could use thrd_sleep()
 
This one doesn't even compile in any of the compiler I have tried:
 
GNU G++,
Embarcadero
Visual Studio 2010, 2013, 2015, 2017
 
Juha Nieminen <nospam@thanks.invalid>: Feb 27 07:17AM

> In C, I'd use fread() and check the return value for a short read.
 
There's nothing wrong in using std::fread() in C++. It's a perfectly
legit standard function.
"James R. Kuyper" <jameskuyper@verizon.net>: Feb 27 08:52AM -0500

On 02/27/2018 02:17 AM, Juha Nieminen wrote:
>> In C, I'd use fread() and check the return value for a short read.
 
> There's nothing wrong in using std::fread() in C++. It's a perfectly
> legit standard function.
 
Yes, I understand that. However, most of <cstdio> has equivalent
functionality within <iostream>, and I want to properly understand what
the <iostream> way of doing such things is. In particular, I was curious
whether either of the two ways of doing this was noticeably superior to
the other. What I've learned is that they're pretty similar for this
kind of task.
The code I'm working on right now is not code that I'm entirely free to
change as I desire - there's a couple of different versions of the
program, and when I make my fix to our version, the people responsible
for the other versions will find it easier to incorporate my fix if it
doesn't require them to switch from <iostream> to <cstdio>. I'd guess
that if I did deliver <cstdio>-based code, they'd assume that I was a C
programmer doing so due to my ignorance of <iostream> (which is mostly -
but not entirely - wrong).
alessio211734 <alessio211734@yahoo.it>: Feb 27 01:19AM -0800

Thanks
alessio211734 <alessio211734@yahoo.it>: Feb 27 01:19AM -0800

Thanks you
alessio211734 <alessio211734@yahoo.it>: Feb 27 01:43AM -0800

> "\n";
> }
> }
 
Hello, nice solution and if I want the possibity to have a circular buffer and for example print if this it's the buffer.
std::vector<float> v={1,2,3};
output:
1 2
2 3
3 1
How can I modify the template to get an iterator to circular buffer?
Paavo Helde <myfirstname@osa.pri.ee>: Feb 27 01:03PM +0200

On 27.02.2018 11:43, alessio211734 wrote:
> 2 3
> 3 1
> How can I modify the template to get an iterator to circular buffer?
 
Circular is slightly more tricky. Currently the IterPair class is
holding 2 iterators which are just incremented in operator++. One could
also store the container begin() and end() in the IterPair class and if
it2_ reaches the end, wrap it over to begin.
 
Cheers
Paavo
Juha Nieminen <nospam@thanks.invalid>: Feb 27 07:19AM

> This is my last post on this forum
 
How many times have we seen this?
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: