4h
answered How to use a void() function to print a vector in c++?
5h
comment How to Defeat a Precognitive Warrior?
... and, of course, it doesn't literally have to be "you can block A or B but not both"; the obvious alternative to taking a strike might be a parry that leaves their guard weakened, and the alternative to taking the next strike might be to be block in a way that leaves them off balance, rendering them unable to stop the third strike.
6h
comment How to Defeat a Precognitive Warrior?
I think most of the comments have misunderstood the key idea here: to force the precog to make a decision before the attacker makes a decision. The precog knows with certainty exactly what the attacker is going to do: strike at whichever the opening the precog leaves. This knowledge doesn't help the precog avoid being struck, unless he can quickly come up with a completely novel defense on the spot, or has the awareness, cleverness, and ability to avoid getting caught in the trap all together. (this comment is not meant to comment on the plausibility of such a trap existing)
8h
comment What sort of punishment would replace fines in a post-scarcity society?
I don't buy that imprisonment, at least with the intent stated here, is any more "enlightened" than physical pain -- its just easier for the average uninvolved person to ignore and less traumatic for the person inflicting the punishment.
11h
comment Dynamically create typedef or change function return type
@lnk: You can make a recursive compile-time template to replace your switch with a half dozen lines of code.
1d
comment Which of these two for loops is more efficient in terms of time and cache performance
It's probably worth noting that there are two issues: how long it takes for memory to get from L2 cache to registers, and the bandwidth between L2 cache and registers. If this were just a matter of latency, then prefetching (either in software or hardware) could eliminate most of the difference between the two ways of accessing the data. The hard limit here, though, is bandwidth; since each memory access reads an entire cache line rather than a single int, then with your assumptions, one access pattern has to read four times as much memory overall.
1d
awarded Nice Answer
1d
comment How define array to fit negative indexes? in C
It's probably worth pointing out that, technically, this is only well-defined if errors is pointing inside the array or one past the end. If the error codes were -6 through -2, the analogous solution would technically be undefined behavior!
1d
awarded Custodian
1d
reviewed Approve suggested edit on Translating new C++ to old C++
Feb
24
awarded Enlightened
Feb
23
revised C++, How to implement Thread pool for tasks when each worker thread has to do few different tasks
added 145 characters in body
Feb
23
answered C++, How to implement Thread pool for tasks when each worker thread has to do few different tasks
Feb
22
answered C++ double pointer output
Feb
22
awarded Nice Answer
Feb
20
awarded Yearling
Feb
20
awarded Yearling
Feb
20
comment how eof function work on cpp?
Instead of A; while(B) { C; A; } you should do while(true) { A; if(!B) { break; } C; }
Feb
20
comment Pointers and references in C++
Generally speaking, you should include the errors in your question when you ask questions like this. Not only do you make things easier on the readers, but it gives them a chance to teach you how to read the errors so you can figure things out yourself!
Feb
20
comment C++ metaprogramming - compile time search tree
From your exposition, it sounds like you really shouldn't be doing what you're trying to do: it sounds like you have a goal of ease of maintainability, and have absolutely no evidence that doing this initialization has any meaningful performance impact at all. Thus, your efforts look like you're trying to optimize something that doesn't matter, which will probably come at the cost of making the thing that does matter worse. In fact, I would advise the opposite of what you're trying to do: find a way to make this list easier to maintain, even if it's at the expense of extra initialization.
1 2 3 4 5