Saturday, February 15, 2014

Can't think of a good subject

Newsgroup: comp.lang.c++

Subject: Can't think of a good subject

From: woodbrian77@...

Date: Wed, 12 Feb 2014 19:45:10 -0800 (PST)





I'm not sure why the behavior of the following

two functions differs here. The only difference

in these functions is in the body of the loop.



template <class R>

void Receive (::cmw::ReceiveBuffer<R>& buf

,empty_container<cmw::File>& az1)

{

int32_t count[1];

count[0]=buf.template Give<uint32_t>();

for(;count[0]>0;--count[0]){

cmw::File inst(buf); // named

}

}





template <class R>

void Receive (::cmw::ReceiveBuffer<R>& buf

,empty_container<cmw::File>& az1)

{

int32_t count[1];

count[0]=buf.template Give<uint32_t>();

for(;count[0]>0;--count[0]){

cmw::File (buf);

}

}





The first (named) version works the way I want

it to, and the second version, built with either

gcc or clang doesn't. Both compilers are

producing smaller text segments for the second

version. And the results for that version

(both compilers) are like nothing is being done

in the loop.



Can someone explain this? In another file I

have some code similar to the second version

and it works fine:



while(fgets(lineBuf,300,Fl.FlHndl)){

token=strtok(lineBuf," ");

if(strcmp("Header",token)) break;

cmw::File (strtok(nullptr,"\n ")).Marshal(buf);

}



I've simplified that loop a little, but don't

think I've removed anything important. There

are different constructors being used in these

two cases.



http://ift.tt/1kJmjpJ



Thanks.



Brian

Ebenezer Enterprises - In G-d we trust.

http://webEbenezer.net







via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://ift.tt/1gDONNy

View all the progranning help forums at:

http://ift.tt/1dP9txN

No comments:

Post a Comment