Type: Posts; User: monarch_dodra
Search took 0.07 seconds.
February 10th, 2016, 03:12 PM
A pointer contains only an address of 1 element. This and nothing else. The pointer itself will not know if it points to a single value, or an array of values, and it will not know how many elements...
February 10th, 2016, 06:04 AM
That won't work with a container. atomics typically work with primitive types. For more complex types, an atomic will basically only support get and set. And both of these will be "pass by value". So...
February 9th, 2016, 11:07 AM
Have you been tasked with re-inventing the logic for that? If not, you can use:
- istream's operator>> http://en.cppreference.com/w/cpp/io/basic_istream/operator_gtgt
- string's "sto" functions...
February 9th, 2016, 05:17 AM
"stdext::hash_map" ? Why not use std::unordered_map ?
Anyways sa rule of thumb, containers are not thread safe. But there is a set of things you *can* do which are guaranteed safe:
- All calls...
February 8th, 2016, 03:49 PM
February 8th, 2016, 03:48 PM
Well, "those work for me" is never proof of anything :) I was using godbolt to test different compiler versions, always with C++11 exclusively (-std=c++11).
Anyways, it would appear gcc accepts...
February 8th, 2016, 03:07 PM
This is not correct. This does not "contruct" the v. It *copies* the v. This is a fundamentally different notion in C++. Copying something over not-yet-initialized is undefined behavior for anything...
February 8th, 2016, 11:43 AM
Those work for me though, as you can always pass a const expression to functions taking const refs.
I can see it being an issue if you want to pass your x to a value taking by const pointer though.
February 7th, 2016, 02:11 PM
I'm not sure that is right, as Cn is never ODR-used to begin with, meaning it does not need to be captured at all. Clang also seems to accept it.
I found this bug report, though it hasn't been...
February 6th, 2016, 02:14 PM
I don't know what the speck say exactly, but given that Cn is const and compile time known, I do not think you need to capture it. Rather, it gets "baked" into the lambda. The code you posted works...
February 5th, 2016, 04:27 AM
You should also consider using accumulate. It takes care of a few more details for you, such as not having to create a variable to accumulate into, or creating a capture in your lambda:
February 4th, 2016, 06:10 AM
consexpr is a way of saying that the variable is declared "const", so that no-one may change it. "constexpr" further means the variable's value is known at compile time, allowing the compiler to use...
February 4th, 2016, 06:04 AM
What you see is something usually called a "console". Honestly, C++ (and C) know nothing about it. All they know is they have a input stream (stdin/std::cin) and a output stream (stdout/std::cout)....
January 25th, 2016, 03:46 AM
It's called *BOOST*. Not "BOOTS".
Not 100% sure but: You wrote the serialization code for your bank, which serializes the map of accounts. But how does it know how to serialize the accounts...
January 2nd, 2016, 08:25 AM
December 31st, 2015, 01:48 PM
Also, note that all the solutions provided so far (mine included) are string based. Why not operate on actual numbers? You can easily test for parity with a bit tests (not forbidden according to...
December 31st, 2015, 01:11 PM
Alternativelly, a lookup array (poor man's hash table) also works.
You can use a "const char*" to save on the space used by the array, at the cost of not using std::string:
December 17th, 2015, 07:18 AM
The issue is not the containers in and out of themselves, but rather, the "raw" pointers: With raw pointers, it is that it is not clear who "owns" the pointer, and who is responsible for deleting...
December 16th, 2015, 03:14 PM
Is that the actual code you you are using? It doesn't even compile. What is "f"? What is "homies"?
Your question seems to imply the code you have at the very least compiled and ran.
December 12th, 2015, 09:13 AM
At the end of the day, it really depends on how the format is defined. Another option to consider is:
Reading each line, using a regex to capture tokens of interest, and then using boost...
December 12th, 2015, 09:00 AM
The spec guarantees that the objects' lifetime will last until the function returns. They *will* be destroyed *after* the function returns. Also, you may only pass temporary variables by reference if...
December 9th, 2015, 01:30 AM
You should straight up return after making a move (recommended). Either that, or make all those "if" "else if"s.
December 7th, 2015, 03:03 PM
You don't want to do that. You are going to run either into memory management issues, or un-maintainable code, VERY quickly.
You probably want to store your objects in std::shared_ptr's, and pass...
December 6th, 2015, 02:37 AM
Right, agreed. I'm just saying that if the original expectation was "if the total cost is close enough, order according to some other criteria", this is something that would virtually never happen....
December 5th, 2015, 11:12 AM
I advise against using an epsilon in an operator, as you'd lose the transitive property of the operator. For example, you could have a==b and b == c, but you'd have a < c. And for operations such as...
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!