comp.lang.c++
http://groups.google.com/group/comp.lang.c++?hl=en
comp.lang.c++@googlegroups.com
Today's topics:
* Return by reference - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/f6dd94c3223a1dbf?hl=en
* Top 20 coding interview problems asked in Google with solutions: Algorithmic
Approach - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/f0866a8c45ecb553?hl=en
* Cracking Programming Interviews: 500 Questions with Solutions - 1 messages,
1 author
http://groups.google.com/group/comp.lang.c++/t/4532417d39af96b4?hl=en
* Getting Started with a Visual Studio C++ 2013 IDE - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/6af661da9c3466bf?hl=en
* about gets - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/0335e4afbf8afe82?hl=en
* beginner - 7 messages, 7 authors
http://groups.google.com/group/comp.lang.c++/t/764088b8acc86a74?hl=en
* pointer to a vector - 9 messages, 4 authors
http://groups.google.com/group/comp.lang.c++/t/b17f744707f37fdb?hl=en
* Can't think of a good subject - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/ff410bf5e81204c2?hl=en
==============================================================================
TOPIC: Return by reference
http://groups.google.com/group/comp.lang.c++/t/f6dd94c3223a1dbf?hl=en
==============================================================================
== 1 of 1 ==
Date: Mon, Feb 10 2014 4:35 am
From: Stuart
>>>On 02/09/14, Giuliano Bertoletti wrote:
>>> which is the difference of calling?
[snip]
>>> ==================
>>> MyClass c;
>>>
>>> SubObject &sub = c.GetSubObject();
>>> SubObject sub = c.GetSubObject();
On 09/02/2014, Marcel Müller wrote:
>> The second line creates a copy of SubObject.
[snip]
On 02/09/14, Giuliano Bertoletti wrote:> ok, thank you.
>
> Is it then safe to call:
>
> c.GetSubObject().SomeFunction()
>
> and expect a straight invocation of the original subobject (not a copy)?
That's right.
Note that such design is frowned upon by some people because it makes
the contract MyClass harder to grasp: Whoever gets access to the
instance of MyClass can also manipulate the sub-object at will. This way
it is not clear why the sub-object is a sub-object of MyClass and not
just an ordinary object that can be manipulated by both MyClass and
everybody else.
If you return a const reference (const SubObject&), however, it becomes
much clearer. The MyClass has full access to the sub-objects, but
clients of MyClass can no longer change MyClass's sub-object but only
retrieve information from it.
Regards,
Stuart
==============================================================================
TOPIC: Top 20 coding interview problems asked in Google with solutions:
Algorithmic Approach
http://groups.google.com/group/comp.lang.c++/t/f0866a8c45ecb553?hl=en
==============================================================================
== 1 of 1 ==
Date: Mon, Feb 10 2014 11:34 am
From: lin.quan.20@gmail.com
http://www.amazon.com/coding-interview-problems-Google-solutions/dp/1495466574/
Must Have for Google Aspirants !!!
This book is written for helping people prepare for Google Coding Interview. It contains top 20 programming problems frequently asked @Google with detailed worked-out solutions both in pseudo-code and C++(and C++11).
Matching Nuts and Bolts Optimally
Searching two-dimensional sorted array
Lowest Common Ancestor(LCA) Problem
Max Sub-Array Problem
Compute Next Higher Number
2D Binary Search
String Edit Distance
Searching in Two Dimensional Sequence
Select Kth Smallest Element
Searching in Possibly Empty Two Dimensional Sequence
The Celebrity Problem
Switch and Bulb Problem
Interpolation Search
The Majority Problem
The Plateau Problem
Segment Problems
Efficient Permutation
The Non-Crooks Problem
Median Search Problem
Missing Integer Problem
==============================================================================
TOPIC: Cracking Programming Interviews: 500 Questions with Solutions
http://groups.google.com/group/comp.lang.c++/t/4532417d39af96b4?hl=en
==============================================================================
== 1 of 1 ==
Date: Mon, Feb 10 2014 11:38 am
From: sergei.nakariakov.5@gmail.com
http://www.amazon.com/Cracking-Programming-Interviews-Questions-Solutions/dp/1495459802/
Part I Algorithms and Data Structures
1 Fundamentals
Approximating the square root of a number
Generating Permutation Efficiently
Unique 5-bit Sequences
Select Kth Smallest Element
The Non-Crooks Problem
Is this (almost) sorted?
Sorting an almost sorted list
The Longest Upsequence Problem
Fixed size generic array in C++
Seating Problem
Segment Problems
Exponentiation
Searching two-dimensional sorted array
Hamming Problem
Constant Time Range Query
Linear Time Sorting
Writing a Value as the Sum of Squares
The Celebrity Problem
Transport Problem
Find Length of the rope
Switch Bulb Problem
In, On or Out
The problem of the balanced seg
The problem of the most isolated villages
2 Arrays
The Plateau Problem
Searching in Two Dimensional Sequence
The Welfare Crook Problem
2D Array Rotation
A Queuing Problem in A Post Office
Interpolation Search
Robot Walk
Linear Time Sorting
Write as sum of consecutive positive numbers
Print 2D Array in Spiral Order
The Problem of the Circular Racecourse
Sparse Array Trick
Bulterman's Reshuffling Problem
Finding the majority
Mode of a Multiset
Circular Array
Find Median of two sorted arrays
Finding the missing integer
Finding the missing number with sorted columns
Re-arranging an array
Switch and Bulb Problem
Compute sum of sub-array
Find a number not sum of subsets of array
Kth Smallest Element in Two Sorted Arrays
Sort a sequence of sub-sequences
Find missing integer
Inplace Reversing
Find the number not occurring twice in an array
3 Trees
Lowest Common Ancestor(LCA) Problem
Spying Campaign
4 Dynamic Programming
Stage Coach Problem
Matrix Multiplication
TSP Problem
A Simple Path Problem
String Edit Distance
Music recognition
Max Sub-Array Problem
5 Graphs
Reliable distribution
Independent Set
Party Problem
6 Miscellaneous
Compute Next Higher Number
Searching in Possibly Empty Two Dimensional Sequence
Matching Nuts and Bolts Optimally
Random-number generation
Weighted Median
Compute a^n
Compute a^n revisited
Compute the product a × b
Compute the quotient and remainder
Compute GCD
Computed Constrained GCD
Alternative Euclid' Algorithm
Revisit Constrained GCD
Compute Square using only addition and subtraction
Factorization
Factorization Revisited
Decimal Representation
Reverse Decimal Representation
Solve Inequality
Solve Inequality Revisited
Print Decimal Representation
Decimal Period Length
Sequence Periodicity Problem
Compute Function
Emulate Division and Modulus Operations
Sorting Array of Strings : Linear Time
LRU data structure
Exchange Prefix and Suffix
7 Parallel Algorithms
Parallel Addition
Find Maximum
Parallel Prefix Problem
Finding Ranks in Linked Lists
Finding the k th Smallest Element
8 Low Level Algorithms
Manipulating Rightmost Bits
Counting 1-Bits
Counting the 1-bits in an Array
Computing Parity of a word
Counting Leading/Trailing 0's
Bit Reversal
Bit Shuffling
Integer Square Root
Newton's Method
Integer Exponentiation
LRU Algorithm
Shortest String of 1-Bits
Fibonacci words
Computation of Power of 2
Round to a known power of 2
Round to Next Power of 2
Efficient Multiplication by Constants
Bit-wise Rotation
Gray Code Conversion
Average of Integers without Overflow
Least/Most Significant 1 Bit
Next bit Permutation
Modulus Division
Part II C++
8 General
9 Constant Expression
10 Type Specifier
11 Namespaces
12 Misc
13 Classes
14 Templates
15 Standard Library
==============================================================================
TOPIC: Getting Started with a Visual Studio C++ 2013 IDE
http://groups.google.com/group/comp.lang.c++/t/6af661da9c3466bf?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 11 2014 4:00 am
From: malcolm.mclean5@btinternet.com
On Saturday, February 1, 2014 4:28:55 AM UTC, W. eWatson wrote:
> I understand C++. What I'm looking for is how one operates the IDE
> provided in VS C++ Desktop. What programming I've done usually does not
> include a sophisticated IDE.
>
I'm basically in the same situation.
I downloaded the latest version of Visual Studio Express for my new Windows 8.1
machine.
Start by creating an empty console project. Then create a C version of "hello world". Get that running, and it means that the compiler is basically set up.
Then try allowing it to make the skeleton for you, still in a console project.
You'll get lots of non-standard stuff, but nothing too awful. Write hello
world out in Unicode. (In Hebrew it's "shalom liolam", shin-lamed-vav-mem
space lamed-ayin-vav-lamed-mem, see if you can get it working in a non-Latin
script).
The try hello world in a window.
Gradually build up, getting more familiar with the IDE as you add complexity.
==============================================================================
TOPIC: about gets
http://groups.google.com/group/comp.lang.c++/t/0335e4afbf8afe82?hl=en
==============================================================================
== 1 of 3 ==
Date: Tues, Feb 11 2014 9:22 am
From: mary8shtr@gmail.com
hi.I am writing a program.while i define some variable but program say this variable undefined.
== 2 of 3 ==
Date: Tues, Feb 11 2014 9:33 am
From: Victor Bazarov
On 2/11/2014 12:22 PM, mary8shtr@gmail.com wrote:
> hi.I am writing a program.while i define some variable but program say this variable undefined.
>
http://www.parashift.com/c++-faq/posting-code.html
V
--
I do not respond to top-posted replies, please don't ask
== 3 of 3 ==
Date: Tues, Feb 11 2014 10:05 am
From: ram@zedat.fu-berlin.de (Stefan Ram)
mary8shtr@gmail.com writes:
>hi.I am writing a program.while i define some variable but program say this variable undefined.
I think this can be done as follows.
#include <iostream>
#include <ostream>
int main(){ int n; ::std::cout << "The variable \"n\" is undefined.\n"; }
==============================================================================
TOPIC: beginner
http://groups.google.com/group/comp.lang.c++/t/764088b8acc86a74?hl=en
==============================================================================
== 1 of 7 ==
Date: Wed, Feb 12 2014 10:01 am
From: frank cubi
Which is the most appropriate website for a person who is learning c++ ?
== 2 of 7 ==
Date: Wed, Feb 12 2014 10:14 am
From: ram@zedat.fu-berlin.de (Stefan Ram)
frank cubi <frankcubi7@gmail.com> writes:
>Which is the most appropriate website for a person who is learning c++ ?
I know some good books:
You can read (in this order and doing the exercise):
Programming -- Principles and Practice Using C++ (only if
you have not programmed before) or Accelerated C++ (if you
have programmed before), The C++ Programming Language,
Effective C++, Exceptional C++ (Parts 1 and 2), Modern
C++ programming, and ISO/IEC 14882:2011.
There also might be websites with similar contents, but
I am not aware of them.
== 3 of 7 ==
Date: Wed, Feb 12 2014 11:03 am
From: Paavo Helde
frank cubi <frankcubi7@gmail.com> wrote in news:9c118022-a702-413b-8ea8-
32da6f631e26@googlegroups.com:
> Which is the most appropriate website for a person who is learning c++ ?
http://www.parashift.com/c++-faq/ is a good one.
== 4 of 7 ==
Date: Wed, Feb 12 2014 11:23 am
From: Cholo Lennon
On 02/12/2014 04:03 PM, Paavo Helde wrote:
> frank cubi <frankcubi7@gmail.com> wrote in news:9c118022-a702-413b-8ea8-
> 32da6f631e26@googlegroups.com:
>
>> Which is the most appropriate website for a person who is learning c++ ?
>
> http://www.parashift.com/c++-faq/ is a good one.
>
Stroustrup's homepage and ISO C++ are also good websites:
http://www.stroustrup.com/
http://isocpp.org/get-started
Regards
--
Cholo Lennon
Bs.As.
ARG
== 5 of 7 ==
Date: Wed, Feb 12 2014 11:27 am
From: Jorgen Grahn
On Wed, 2014-02-12, Stefan Ram wrote:
> frank cubi <frankcubi7@gmail.com> writes:
>>Which is the most appropriate website for a person who is learning c++ ?
>
> I know some good books:
>
> You can read (in this order and doing the exercise):
> Programming -- Principles and Practice Using C++ (only if
> you have not programmed before) or Accelerated C++ (if you
> have programmed before), The C++ Programming Language,
> Effective C++, Exceptional C++ (Parts 1 and 2), Modern
> C++ programming, and ISO/IEC 14882:2011.
>
> There also might be websites with similar contents, but
> I am not aware of them.
Me neither. https://www.sgi.com/tech/stl/ is the only one I use. And
/The C++ Programming Language/ is the only book I've read and liked.
However, this mostly means I learned C++ slowly, and started a long
time ago ...
Apart from that I recommend:
- writing lots of code
- reading lots of code
- learning your tools
- hanging out on comp.lang.c++ and comp.lang.c++.moderated
Happy hacking!
/Jorgen
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
== 6 of 7 ==
Date: Wed, Feb 12 2014 1:16 pm
From: woodbrian77@gmail.com
On Wednesday, February 12, 2014 1:27:31 PM UTC-6, Jorgen Grahn wrote:
> On Wed, 2014-02-12, Stefan Ram wrote:
>
> > frank cubi <frankcubi7@gmail.com> writes:
>
> >>Which is the most appropriate website for a person who is learning c++ ?
>
> >
>
> > I know some good books:
>
> >
>
> > You can read (in this order and doing the exercise):
>
> > Programming -- Principles and Practice Using C++ (only if
>
> > you have not programmed before) or Accelerated C++ (if you
>
> > have programmed before), The C++ Programming Language,
>
> > Effective C++, Exceptional C++ (Parts 1 and 2), Modern
>
> > C++ programming, and ISO/IEC 14882:2011.
>
> >
>
> > There also might be websites with similar contents, but
>
> > I am not aware of them.
>
>
>
> Me neither. https://www.sgi.com/tech/stl/ is the only one I use. And
> /The C++ Programming Language/ is the only book I've read and liked.
> However, this mostly means I learned C++ slowly, and started a long
> time ago ...
>
> Apart from that I recommend:
> - writing lots of code
> - reading lots of code
I have an archive here:
http://webEbenezer.net/build_integration.html
That you're welcome to download and read.
The code uses some of the newer features
of the language.
Brian
Ebenezer Enterprises
http://webEbenezer.net
== 7 of 7 ==
Date: Wed, Feb 12 2014 1:44 pm
From: "K. Frank"
Hello Frank!
On Wednesday, February 12, 2014 1:01:15 PM UTC-5, frank cubi wrote:
> Which is the most appropriate website for a person who is learning c++ ?
As Paavo mentioned,
http://www.parashift.com/c++-faq/
is a good place to start.
(Some minor caveats: It can be a little overly prescriptive;
it's philosophy is a bit too narrowly object oriented; and
it's showing its age a little. One pet peeve of mind is that
the web site's format became overly fragmented a few years ago.)
For features added in the most recent standard (already a few
years ago) Stroustrup's C++11 FAQ is very good:
http://www.stroustrup.com/C++11FAQ.html
Two good (not perfect) reference sites are:
http://en.cppreference.com/w/
and
http://www.cplusplus.com/reference/
(or if you prefer, http://www.cplusplus.com/).
Stefan's book suggestions are very good.
Also, although not technically a web site, this usenet group
(or its moderated companion, comp.lang.c++.moderated) is a
good place to post specific, single-topic questions when you
come across something you don't understand or don't see how
to do. (If you're learning, you'll get better answers if
you do your homework first.)
Happy Hacking!
K. Frank
==============================================================================
TOPIC: pointer to a vector
http://groups.google.com/group/comp.lang.c++/t/b17f744707f37fdb?hl=en
==============================================================================
== 1 of 9 ==
Date: Wed, Feb 12 2014 11:46 am
From: "A"
There are 2 vectors each one having a structure
struct MyStruct
{
int a;
std::string b;
}
std::vector<MyStruct> v1;
std::vector<MyStruct> v2;
Now I want a pointer to which one I will use... v1 or v2
std::vector<MyStruct> *v = (condition)? &v1 : &v2;
Finally I access it using:
for (unsigned i = 0; i < v->size(); i++)
{
v->operator[](i).a = i + 1;
}
My lack of understanding here is:
a) does the above *v needs to be deleted? Isn't it just a pointer variable?
Or it works differently when it points to a vector? Just to be clear, I
don't actually need to delete v1 or v2. I just need to cleanup *v if
required.
b) what's the heap or stack or difference or advantage of them in relation
to the above?
== 2 of 9 ==
Date: Wed, Feb 12 2014 11:51 am
From: "A"
Actually I just found that I can use *v like this:
(*v)[i].a = i + 1;
Cleaner to me than
v->operator[](i).a = i + 1;
However, my questions are still the same.
== 3 of 9 ==
Date: Wed, Feb 12 2014 12:11 pm
From: Paavo Helde
"A" <a@a.a> wrote in news:ldgj2i$2gc$1@gregory.bnet.hr:
> There are 2 vectors each one having a structure
>
> struct MyStruct
> {
> int a;
> std::string b;
> }
>
> std::vector<MyStruct> v1;
> std::vector<MyStruct> v2;
>
> Now I want a pointer to which one I will use... v1 or v2
>
> std::vector<MyStruct> *v = (condition)? &v1 : &v2;
>
> Finally I access it using:
>
> for (unsigned i = 0; i < v->size(); i++)
> {
> v->operator[](i).a = i + 1;
> }
You can also use references:
std::vector<MyStruct> & v = (condition)? v1 : v2;
...
v[i].a = i+1;
>
> My lack of understanding here is:
>
> a) does the above *v needs to be deleted? Isn't it just a pointer
> variable? Or it works differently when it points to a vector? Just to
> be clear, I don't actually need to delete v1 or v2. I just need to
> cleanup *v if required.
No, as a rule of thumb, if your code does not contain 'new' then there is
no need for 'delete' either (and this is a good thing). Any dynamically
allocated memory is maintained and released by the std::vector objects
internally.
>
> b) what's the heap or stack or difference or advantage of them in
> relation to the above?
std::vector automatically stores the stuff in the right place, you do not
need to worry about this. Just avoid raw arrays and 'new' (as you have
done so far) and you should be fine.
Cheers
Paavo
== 4 of 9 ==
Date: Wed, Feb 12 2014 12:12 pm
From: Jorgen Grahn
On Wed, 2014-02-12, A wrote:
> There are 2 vectors each one having a structure
>
> struct MyStruct
> {
> int a;
> std::string b;
> }
>
> std::vector<MyStruct> v1;
> std::vector<MyStruct> v2;
>
> Now I want a pointer to which one I will use... v1 or v2
>
> std::vector<MyStruct> *v = (condition)? &v1 : &v2;
You don't need a pointer below -- a reference would have worked just
as well, and the syntax would have been cleaner.
> Finally I access it using:
>
> for (unsigned i = 0; i < v->size(); i++)
> {
> v->operator[](i).a = i + 1;
> }
>
> My lack of understanding here is:
>
> a) does the above *v needs to be deleted? Isn't it just a pointer variable?
No, and yes. You haven't done 'new', so you're not responsible for
doing 'delete'. BTW, both of those are rarely needed in modern code
-- if you use them a lot you're probably doing something wrong.
> Or it works differently when it points to a vector? Just to be clear, I
> don't actually need to delete v1 or v2. I just need to cleanup *v if
> required.
No cleanup required. But I don't really understand what you're trying
to say ...
> b) what's the heap or stack or difference or advantage of them in relation
> to the above?
I don't understand that question. Please rephrase.
/Jorgen
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
== 5 of 9 ==
Date: Wed, Feb 12 2014 12:32 pm
From: "A"
"Jorgen Grahn" <grahn+nntp@snipabacken.se> wrote in message
news:slrnlfnle0.81f.grahn+nntp@frailea.sa.invalid...
> No, and yes. You haven't done 'new', so you're not responsible for
> doing 'delete'. BTW, both of those are rarely needed in modern code
> -- if you use them a lot you're probably doing something wrong.
No, I don't use normally new or delete. I use boost smart pointers and
vectors.
Good thing to know this rule of a thumb - using new = delete, not using it,
then it is just a pointer.
> No cleanup required. But I don't really understand what you're trying
> to say ...
What I though is that if it is pointer to a vector then it is somehow
different but obviously it is just a same pointer like any other. So yes,
then no cleanup is required, it is just a pointer variable.
>> b) what's the heap or stack or difference or advantage of them in
>> relation
>> to the above?
> I don't understand that question. Please rephrase.
A guy here was mentioning heap so I though it was related. Seems it is not:
http://facepunch.com/showthread.php?t=780439
== 6 of 9 ==
Date: Wed, Feb 12 2014 12:34 pm
From: "A"
"Paavo Helde" <myfirstname@osa.pri.ee> wrote in message
news:XnsA2D2E1C8E2580myfirstnameosapriee@216.196.109.131...
> No, as a rule of thumb, if your code does not contain 'new' then there is
> no need for 'delete' either (and this is a good thing). Any dynamically
> allocated memory is maintained and released by the std::vector objects
> internally.
That's a good rule to remember. So it is just a plain pointer. Thanks!
> std::vector automatically stores the stuff in the right place, you do not
> need to worry about this. Just avoid raw arrays and 'new' (as you have
> done so far) and you should be fine.
Yes, haven't been using new/delete in years since I discovered smart
pointers and vectors.
== 7 of 9 ==
Date: Wed, Feb 12 2014 12:43 pm
From: ram@zedat.fu-berlin.de (Stefan Ram)
"A" <a@a.a> writes:
>There are 2 vectors each one having a structure
>std::vector<MyStruct> v1;
>std::vector<MyStruct> v2;
IIRC, the default constructor constructs an /empty/ vector.
This means that /neither/ vector so far has a structure.
== 8 of 9 ==
Date: Wed, Feb 12 2014 1:01 pm
From: Jorgen Grahn
On Wed, 2014-02-12, A wrote:
> "Jorgen Grahn" <grahn+nntp@snipabacken.se> wrote in message
> news:slrnlfnle0.81f.grahn+nntp@frailea.sa.invalid...
[...]
>>> b) what's the heap or stack or difference or advantage of them in
>>> relation
>>> to the above?
>> I don't understand that question. Please rephrase.
>
> A guy here was mentioning heap so I though it was related. Seems it is not:
> http://facepunch.com/showthread.php?t=780439
I don't know which of them, but several of them seem rather confused.
You'll get better answers here, with the right questions.
/Jorgen
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
== 9 of 9 ==
Date: Thurs, Feb 13 2014 5:23 am
From: "A"
"Stefan Ram" <ram@zedat.fu-berlin.de> wrote in message
news:vector-20140212214210@ram.dialup.fu-berlin.de...
> IIRC, the default constructor constructs an /empty/ vector.
> This means that /neither/ vector so far has a structure.
Of course, I know that - that was just a dumb example. Thanks for pointing
this out though. Much appreciate the effort.
==============================================================================
TOPIC: Can't think of a good subject
http://groups.google.com/group/comp.lang.c++/t/ff410bf5e81204c2?hl=en
==============================================================================
== 1 of 2 ==
Date: Wed, Feb 12 2014 7:45 pm
From: woodbrian77@gmail.com
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://webEbenezer.net/misc/File.hh
Thanks.
Brian
Ebenezer Enterprises - In G-d we trust.
http://webEbenezer.net
== 2 of 2 ==
Date: Thurs, Feb 13 2014 9:00 am
From: Bo Persson
woodbrian77@gmail.com skrev 2014-02-13 04:45:
>
> 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.
The second version also declares a named variable, buf. Parenthesis are
optional when declaring variables.
Bo Persson
==============================================================================
You received this message because you are subscribed to the Google Groups "comp.lang.c++"
group.
To post to this group, visit http://groups.google.com/group/comp.lang.c++?hl=en
To unsubscribe from this group, send email to comp.lang.c+++unsubscribe@googlegroups.com
To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.c++/subscribe?hl=en
To report abuse, send email explaining the problem to abuse@googlegroups.com
==============================================================================
Google Groups: http://groups.google.com/?hl=en
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment