Friday, May 6, 2016

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

Ralf Goertz <me@myprovider.invalid>: May 06 10:13AM +0200

Am Wed, 4 May 2016 16:26:09 +0000 (UTC)
 
> >auto it=std::find(v.begin(),v.end(),value);
 
> It's coming.
 
> <http://ericniebler.com/2014/10/11/n4128-ranges-for-the-standard-library/>
 
That's exactly what I was hoping for, thanks.
legalize+jeeves@mail.xmission.com (Richard): May 06 04:14PM

[Please do not mail me a copy of your followup]
 
Ralf Goertz <me@myprovider.invalid> spake the secret code
 
>> It's coming.
 
>> <http://ericniebler.com/2014/10/11/n4128-ranges-for-the-standard-library/>
 
>That's exactly what I was hoping for, thanks.
 
Depending on your compiler you can use the library today:
<https://github.com/ericniebler/range-v3>
 
It needs more SFINAE support than VS 2015 Update 2 is currently
offering, but I'm sure MS is working on improving that.
--
"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>
bleachbot <bleachbot@httrack.com>: May 06 02:03AM +0200

bleachbot <bleachbot@httrack.com>: May 06 02:42AM +0200

ram@zedat.fu-berlin.de (Stefan Ram): May 06 01:57AM

> text_buffer_.handle, impl::winapi::Output_flags::Enum()
> );
> }
 
I don't get it. What does this that the following does not?
 
Impl( const Point size )
: text_buffer_()
, info_( text_buffer_.handle )
, text_buffer_activation_( text_buffer_.handle )
{
{
Console_info params = info_.api_info();
 
params.dwSize = {short( size.x ), short( size.y )};
params.dwCursorPosition = {};
//screen.wAttributes = bitsForBgFg(
params.srWindow = {0, 0, short( size.x - 1 ), short( size.y - 1 )};
params.dwMaximumWindowSize = params.dwSize;
info_.make_real( params );
}
impl::winapi::set_output_mode(
text_buffer_.handle, impl::winapi::Output_flags::Enum()
);
}
 
Regarding lambdas and withs, I'd have thought more in the
direction of
 
#include <stdio.h>
#include <functional>
 
void with_open_file
( const char * const filename, const char * const mode,
::std::function<void(FILE *)> client )
{ FILE * f = fopen( filename, mode );
if( f )client( f );
fclose( f ); }
 
int main()
{ with_open_file( "C:\\example\\test.txt", "w",
[]( FILE * f ){ fprintf( f, "test\n" ); }); }
 
Of course, in C++ this style of withs todays is needed
rarely because in C++ RAII is a better solution of the
same problem. But this is what a with is to me.
ram@zedat.fu-berlin.de (Stefan Ram): May 06 02:27PM

>You're right, a simple curly braces block with appropriate comment is
>equally clear.
 
In a couse, a participant once asked be about the meaning
of a programm like
 
int main()
{ auto x{ 1 };
{ x = 2; } /**/
/* what is the value of x here? */ }
 
. He wanted to know whether the assignment was abolished by
the »} /**/«. I replied that it was not abolished by the »} /**/«.
 
But today, we can have something like this:
 
int main1()
{ auto x{ 1 };
[ = ]() mutable { x = 2; } /**/ ();
/* what is the value of x here? */ }
 
In the program directly above, the »} /**/« in fact /does/
abolish the assignment of »2« to »x«, and »x« is »1« again
at »/* what is the value of x here? */«.
 
Maybe someday this will come in handy for something.
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: May 06 03:32AM +0200

I just now found occasion to use a lambda expression as a "with"-block:
 
Impl( const Point size )
: text_buffer_()
, info_( text_buffer_.handle )
, text_buffer_activation_( text_buffer_.handle )
{
[&](){
Console_info params = info_.api_info();
 
params.dwSize = {short( size.x ), short( size.y )};
params.dwCursorPosition = {};
//screen.wAttributes = bitsForBgFg(
params.srWindow = {0, 0, short( size.x - 1 ), short( size.y
- 1 )};
params.dwMaximumWindowSize = params.dwSize;
info_.make_real( params );
}();
impl::winapi::set_output_mode(
text_buffer_.handle, impl::winapi::Output_flags::Enum()
);
}
 
(The Hungarian notation names are Microsoft's, not mine. Side note: what
does one call something when Microsoft calls it "info"? In this case
it's a set of values that specify the properties of a console.)
 
Yes, it's a far cry from a dedicated syntax, but still it gets the job done.
 
At one time in the C++03 days I created an awesome WITH macro based on
"for" I think it was, but I never used it more than the original single
use case...
 
 
Cheers,
 
- Alf
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: May 06 12:41PM +0200

On 06.05.2016 03:57, Stefan Ram wrote:
> text_buffer_.handle, impl::winapi::Output_flags::Enum()
> );
> }
 
You're right, a simple curly braces block with appropriate comment is
equally clear.
 
It was a late night posting, sorry. I had planned to have the "params"
variable, the logical "with" variable, as a default-initialized formal
argument to the lambda. But the initializer expression, using a member
variable, can't be used as initializer for a formal argument because the
outer this can't be captured in the formal argument list.
 
So it was like triple dumb, sorry. But when I posted it it looked neat. :)
 
 
 
> Of course, in C++ this style of withs todays is needed
> rarely because in C++ RAII is a better solution of the
> same problem. But this is what a with is to me.
 
Yes yes.
 
 
Cheers!, & thanks,
 
- Alf
Jorgen Grahn <grahn+nntp@snipabacken.se>: May 06 06:23AM

On Thu, 2016-05-05, Heinz-Mario Frühbeis wrote:
 
>> More generally, please describe the goal you are trying to achieve and
>> why you think this specific task is the way to achieve it.
 
> Isn'T it self-declaring?
 
No. He asked for a use case.
 
And I suspect he asked because
 
a) He didn't really understand what you want (I didn't either).
 
b) If you show your real-life problem, people will be familiar with it
and tell you how they deal with it. It's not unlikely that someone
has a different, better solution.
 
Do you perhaps have a Python background? People here have experience
mapping Python solutions to C++ solutions, too.
 
 
> Currently I use void* to store a member in a vector and I, if used, cast
> this void-pointer into a template-function. This works, (IMHO) less
> coding...
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
Ramine <ramine@1.1>: May 05 08:43PM -0700

Hello......
 
 
I have come to an interesting subject ?
 
This time about softwares..
 
As you have noticed i have described also computer programming
as Petri Nets and there is a proof that Petri Nets with
inhibitor arcs have the same power an expressiveness as
a Turing machine.. now i think there is a weakness in the software
industry, since we can make software products much
more faster than hardware products by automating it, i think
that there is a risk that a minority of us software engineers
will monopolize the industry of softwares, because i think
since we are automating it faster and faster using fewer programmers,
this risk is lesser i think than the hardware industry.
 
 
 
Thank you,
Amine Moulay Ramdane.
Ramine <ramine@1.1>: May 05 08:06PM -0700

Hello,
 
 
Now i have come to an interesting subject..
 
What is computer programming and is it a science ?
 
I was just thinking about this question and since i am
a guy who specializes in parallel programming, i will
answer this question this way:
 
I have done Petri Nets and there is a proof that Petri Nets
with inhibitor arcs have the same power and expressiveness
as a Turing machine, so i think that computer programming is
like constructing Petri Nets or is like constructing automata,
i think an object in C++ can be represented like an automaton,
and methods of a C++ object can be represented like an automaton,
so computer programming thinking is like constructing many
interconnected automaton and is like constructing Petri Nets,
and my second question is: Is computer programming a science ?
i think computer programming can be made a science by making those many
interconnected automaton or those Petri Nets more efficient.
This is how i think computer programming can be described.
 
 
 
Thank you,
Amine Moulay Ramdane.
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: