Monday, December 14, 2015

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

"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Dec 14 05:20PM +0100

https://connect.microsoft.com/VisualStudio/feedback/details/2128262
 
auto main() -> int
{
return __STDC_HOSTED__;
}
 
does not compile with Visual C++ 2015.
 
Bah!
 
 
- Alf
mark <mark@invalid.invalid>: Dec 14 10:31PM +0100

On 2015-12-14 17:20, Alf P. Steinbach wrote:
> Re: Second MSVC bug in 2 days, hm.
 
You must be quite gentle on the compiler, if you only encountered 2 bugs.
 
If you want to enjoy compiler crashes, play around with constexpr.
legalize+jeeves@mail.xmission.com (Richard): Dec 14 07:30PM

[Please do not mail me a copy of your followup]
 
=?UTF-8?Q?Tobias=20M=C3=BCller?= <troplin@bluewin.ch> spake the secret code
 
>I'm not saying that runtime polymorphism is generally bad and templates
>should always be preferred. But if you need the performance it's a valid
>alternative for achieving DI.
 
I find that since I started doing TDD and incremental design, I use
runtime polymorphism more than I did before. I pay a small runtime
penalty (function indirection) but gain testability and more explicit
design abstractions than I did before. The design abstractions have
increased my ability to not only test my code, but reason about my
code and in some cases take my code into other unexpected directions
more easily.
 
It's funny how all the stuff they told you about good OOD principles
(SOLID, etc.) come naturally as a consequence of doing TDD.
--
"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>
Bo Persson <bop@gmb.dk>: Dec 14 05:00PM +0100

On 2015-12-13 20:30, JiiPee wrote:
> createArray(len=10, capacity=20);
 
> would give a compiler error because the first must be
> length
 
Stefan tried to show you that your code already has a meaning in both C
and C++ - assigning and passing the value at the same time.
 
In your last example, a global
 
int len;
 
would remove the compiler error and assign 10 to len.
 
 
Bo Persson
mark <mark@invalid.invalid>: Dec 14 03:32PM +0100

On 2015-12-13 16:57, Stefan Ram wrote:
>> the first place?
 
> I post my C++ source code below. This is raw source code as is;
> [...]
 
There is nothing wrong with your code, it's not spending time in the
kernel. What you are seeing in the stack trace is an artifact of the
tool you are using to capture the stack trace (try a real debugger or
profiler).
ram@zedat.fu-berlin.de (Stefan Ram): Dec 13 03:57PM

>Are you sure this a stack trace from your collection processing code in
>the first place?
 
I post my C++ source code below. This is raw source code as is;
i.e., it is not cleaned up yet, so it might have stylistic issues;
it might contain »goto«s, file-scope variables, or lines with more than 72 characters.
 
In the meantime, I have replaced the »::std::vector«s with two
arrays with automatic storage duration; the stack should have
at least 300'000 octets.
 
If someone happens to use Microsoft® Windows with
Sysinternals Process Explorer, he can then start the program
and select the process' properties in Sysinternals Process
Explorer, go to the page »Threads« and select »Stack«.
Or maybe he has some other appropriate debugging tool at hand.
 
The effect can be observed with /any/ compiler options; just
for information, the following gcc compiler options express
my intent to make it fast. But you do not have to use these
options to see the effect.
 
// -msse2 -march=native -Ofast -O3 -std=c++14 -pedantic
// -pedantic-errors -Werror=narrowing -Wall -W -Wconversion
// -Wextra -Weffc++ -Wno-parentheses -Wno-unused-parameter
// -Wno-unused-variable -pthread
 
Search for »INNER LOOP« below to see the part that I think
needs to run fast and which I expect to use nearly all of
the processor time.
 
#define NDEBUG 1
#include <iostream> // ::std::cout
#include <ostream> // <<
#include <climits>
 
using NUMBER = unsigned int;
NUMBER * collection;
NUMBER * next_collection;
 
// to compile this with any other compiler, the
// "__attribute__ ((aligned))" might have to be removed.
typedef NUMBER FAST[ 32768 ] __attribute__ ((aligned));
 
long const cardsize = 5; /* number of symbols per card */
NUMBER const symbols[] ={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
 
static inline only_one_bit_set( NUMBER const i ){ return i && !( i & ( i - 1 )); }
 
extern void visit_t( NUMBER const * const set, NUMBER const * const c, NUMBER const n );
extern void visit_s( NUMBER const * const set, NUMBER const * const c, NUMBER const n );
 
int stop_enum = 0;
 
void enum_subset
( NUMBER const * const set, NUMBER const n, NUMBER const m, void( * visit )( NUMBER const * const set, NUMBER const * c, NUMBER n ))
{ NUMBER j; NUMBER * c = new( ::std::nothrow )NUMBER[ n + 3 ];
if( c != nullptr )
{ for( j = 1; j <= n; ++j )
c[ j ]= j - 1;
c[ n + 1 ]= m; c[ n + 2 ]= 0; loop: goto visit;
next: for( j = 1; c[ j ]+ 1 == c[ j + 1 ]; ++j )c[ j ]= j - 1;
if( j > n )goto end; c[ j ]= c[ j ]+ 1; goto loop;
 
visit:
visit( set, c, n );
if( stop_enum )return;
goto next;
 
end:
delete[] c; }}
 
size_t const symbolcount = sizeof symbols / sizeof 0[ symbols ];

/** @brief generate the set of a cards with symbolcount symbols and write it into the vector cards */
void generate_t( )
{ // assert( cardsize <= symbolcount );
enum_subset( symbols, cardsize, symbolcount, visit_t ); }
 
/** @brief write this set as a card into the cards */
void visit_t( NUMBER const * const set, NUMBER const * const c, NUMBER const n )
{ long menge = 0;
for( size_t i = 1; i <= n; ++i )menge |= 1 <<( set[ c[ i ]] );
*next_collection++ = menge; }
 
static size_t checking = 0;
 
void showcheck( size_t const i )
{ if( i > checking )
{ ::std::cout << "now checking selections of size " << i << "\n";
checking = i; }}
 
void print( NUMBER const * const set, NUMBER const * const c, NUMBER const n )
{ ::std::cout << "Game found: number of cards = " << n;
if( !n )::std::cout << ".\n"; else
{ ::std::cout << ", set of cards = \n{";
for( size_t k = 1; k <= n; ++k )
{ ::std::cout <<( k == 1 ? " {": " {" );
for( NUMBER l = 0; l < sizeof( NUMBER )* CHAR_BIT; ++l )
{ if( set[ c[ k ]]&(( NUMBER )1 << l ))::std::cout << ' ' << l; }
::std::cout <<( k == n ? " }}.\n" : " }\n" ); }
return; }}
 
void enum_fast
( NUMBER const n )
{ FAST array;
NUMBER * const c = array;
NUMBER const * const set = collection;
NUMBER const m =( NUMBER )( next_collection - collection );
NUMBER j;
if( c != nullptr )
{ for( j = 1; j <= n; ++j )c[ j ]= j - 1;
c[ n + 1 ]= m;
c[ n + 2 ]= 0;
 
/* INNER LOOP */
while( 1 )
{ for( NUMBER k = 1; k <= n; ++k )
{ NUMBER const p = set[ c[ k ]];
for( NUMBER l = 1; l < k; ++l )
{ NUMBER const a = p & set[ c[ l ]];
if( !( a && !( a &( a - 1 ))))goto out; }}
 
print( set, c, n );
return;
 
out:
for( j = 1; c[ j ]+ 1 == c[ j + 1 ]; ++j )c[ j ]= j - 1;
if( j > n )return;
 
c[ j ]= c[ j ]+ 1; }}}
 
/** @brief generate the cards selections and check them for the dobble property */
void generate_s()
{ NUMBER const collectionsize =( NUMBER )( next_collection - collection );
::std::cout << "collectionsize = " << collectionsize << "\n";
for( NUMBER subsetsize = 0; subsetsize <= collectionsize; ++subsetsize )
{ stop_enum = 0;
enum_fast( subsetsize ); }}
 
int main1()
{
FAST collection_;
collection = collection_;
next_collection = collection_;
 
::std::cerr << "generating collection ...\n";
generate_t();
 
::std::cerr << "searching selections for games ...\n";
generate_s();
return 0; }
 
 
int main()
{ return main1(); }
"J. Clarke" <j.clarke.873638@gmail.com>: Dec 13 08:26AM -0500

In article <80f49ad2-4217-426c-ae74-07a2236a4dd8@googlegroups.com>,
gizmomaker@bigpond.com says...
> And send the law to your place if it looks dubious.
 
> They already use this on One Drive etc and Google use it on their social sites.
> It does not even allow nudity on One Drive.
 
Source?
 
Oh, make sure that you'pre looking at the rules for private storage, not
for shared content.
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: