Type: Posts; User: laserlight
Search took 0.14 seconds.
I suggest that you separate this function into two functions:
bool checkValidPhoneNumber(const std::string& phoneNumber);
void readPhoneNumber(std::string& phoneNumber);
You would place all the...
You observed the effects of the comma operator. That is, the comma operator has a lower precedence than the copy assignment operator, so this:
lLag1 = 5, 6;
is equivalent to:
(lLag1 = 5), 6;...
Since you chose to overload operator< for AStarNodePair, you no longer need AStarNodePairComparator. However, I notice that you suddenly switched to std::set.
August 27th, 2015, 01:03 PM
So, what is the problem that you're having with the sum?
August 25th, 2015, 09:41 AM
You cannot overload operator< with both parameters of pointer type though, hence my suggestion of a named function or function object to serve as the comparator.
August 24th, 2015, 05:43 AM
Reading MSDN on TryEnterCriticalSection, perhaps the appropriate header was not included.
August 24th, 2015, 05:35 AM
Because you overloaded operator< such that a AStarNodePair object is expected on the left hand side but a AStarNodePair pointer is expected on the right hand side. This is consequence of overloading...
August 24th, 2015, 05:05 AM
What is the exact type of the std::map?
You meant overload, not override. The term override is used specifically when you want to override a virtual function. Anyway, std::map uses operator< by...
August 20th, 2015, 04:19 AM
I see. Thanks!
Yeah, I recall reading Stepanov, if I remember correctly, arguing that ranges would be superior to explicit iterator pairs, but I was unaware that such a proposal might actually...
August 20th, 2015, 03:04 AM
That looks good. Could you link to the relevant proposal?
August 20th, 2015, 02:27 AM
That's a good point: part of readability depends on the reader's familiarity with the paradigms in use. Yet, C++ is multiparadigm, so I do not see a problem with mixing and matching, hence I disagree...
August 19th, 2015, 11:47 AM
No, my post #16 is a reply to your post #18. That is why I found it strange, but yeah, "posted then deleted" does explain it. Talk about concurrency :D
Anyway, to address your additional points:
August 19th, 2015, 11:27 AM
Weird, did the posts go out of sync? I was fairly certain that I was replying to tiliavirga's post, but it looks like my post now appears before the post that I was responding to.
August 19th, 2015, 11:22 AM
I don't quite understand what you mean by "structure over logic" here though: isn't the structure entirely a logical structure?
One advantage of using the generic algorithm is that the abstraction...
August 19th, 2015, 09:58 AM
In themselves, nothing, except that in this case the std::find generic algorithm expresses the intent more clearly with a name and removes the need to break out of nested loops with a goto as the...
August 19th, 2015, 09:11 AM
Aye, it looks like a strange decision to me, especially since it would eliminate the need for a goto to break out of the nested loops. Besides, I get the impression that bFound exists solely to...
August 18th, 2015, 11:44 PM
The problem is that you have a vector of pointers to Value. The Value class does not have a member named value. Hence, you need to cast the pointer to Value to be a pointer to whatever derived class...
August 18th, 2015, 12:22 PM
Why do you want to do this? If Object were a polymorphic base class, you could use dynamic_cast to achieve this, but it would be better if you declared a virtual function in the base class that each...
August 18th, 2015, 11:45 AM
std::find would suffice, and I think that it would be appropriate:
const std::vector<string>& strvec = iIter->second;
if (std::find(strvec.begin(), strvec.end(), sSessionId) != strvec.end())
August 18th, 2015, 11:02 AM
The map only maps one way, so you have to go over the mapped values (i.e., the vectors) and search each vector to find the given Rx session Id.
August 14th, 2015, 07:09 AM
Well, that is what namespaces are for, though I am not sure if strdup would also be in the std namespace since being POSIX standard only it is not part of the standard library, and besides there is...
August 13th, 2015, 09:59 AM
Especially since there is a POSIX standard function named strdup which has the same parameter list and return type, and which does obtain storage using malloc.
August 13th, 2015, 02:59 AM
You duplicated a null terminated string but forgot to null terminate your duplicate, and in fact you did not even allocate enough space for the null character (having hard coded 4 instead of using...
August 6th, 2015, 02:17 AM
Obviously, you can keep an array (or vector) sorted. The problem (and this is a general algorithm and data structure problem, not one limited to C++) is that an insertion into the middle of an...
August 4th, 2015, 08:37 AM
As in with pass by value or with a const lvalue reference parameter?
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!