Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Code that is written to the 2011 version of the C++ standard, sometimes known by its pre-publication name of "C++0x". Use in conjunction with the 'c++' tag.
2
votes
Accepted
Calculation of Energy Spectrum using C++
In parallel programming, it's often useful to try to minimize the degree to which the threads work with the same data. In this case, you have all the threads doing updates to E almost constantly throu …
1
vote
Accepted
emplace_back is faster than allocate once + move in c++11?
[I'm reviewing this because I believe that both f and f2 actually work; I think the discussion of "different call tree" is just talking about difficulty in profiling them meaningfully.]
From a code q …
3
votes
Random line remover from file
Use the force library Luke!
Your code does use std::vector, but for reasons I don't understand, it also uses new to allocate a manually managed dynamic array as well. You don't seem to gain anything …
3
votes
Accepted
String algorithms and locale
I think I'd prefer to have the user pass a locale instead of a facet. In most typical cases, a user will deal only with locales, not with the individual facets that make up a particular locale. It's a …
12
votes
Accepted
UDP Network server/client for gaming using boost.asio
Exception safety
Your locked_queue isn't exception safe. In particular:
queue.pop();
return value;
If the copy (or move) constructor for _T throws, you could have popped the item from the …
5
votes
Accepted
STL Performance micro-benchmark
Side note: this is a code review site, so I'm going to at least start by reviewing your actual code. I might try to add a few points about what you tried to investigate later, but for now this is most …
8
votes
Binary Search implemented in C++
Space Complexity
This is quite inefficient in terms of the storage space it uses.
Assuming the bisection works as we'd hope, and the vector is cut exactly in half every time, the recursive call copi …
6
votes
Translate a day in year to month and day 2nd method
If you were doing this in real life under normal circumstances, I'd expect to use the standard library to do essentially the entire job. In particular, I'd avoid doing any of the computation myself, g …
7
votes
Multithread to print odd and even numbers
I agree with @janos that threads are a poor fit for this problem.
Modularity
If you're going to use threads anyway, I'd at least attempt to get rid of the global variables, and the dependencies betw …
8
votes
Simple Encryption for Strings
While I agree with the general idea of most of what Toby Speight says, for this case, I'd tend to avoid using a map, and instead just use a contiguous table, something on this general order:
#include …
6
votes
Calendar for any given month/year
I found the basic model of how the program works more annoying than useful. I'd expect typing just "cal" to pick a reasonable default, such as displaying the calendar for the current month (and possib …
4
votes
Accepted
General purpose code performance measurement on Windows
Timer Design
I'm not a big fan of most software patterns, but this looks to me like a nearly perfect fit for one that I think really is quite useful--the strategy pattern.
In this case, each perform …
6
votes
LockGuard for MFC CMutex
Instead of writing your own lock_guard-like object specifically to use with a CMutex, I'd write a wrapper for CMutex to give it the Lockable interface, then just use it with a normal std::lock_guard:
…
6
votes
Accepted
Creating URL with Builder pattern
Include the required headers
You use std::string extensively, but you don't include <string>. This is allowed to work (any standard header is allowed to act as if it includes any or all others), but …
7
votes
Accepted
Implementation of LRU cache
Namespace Usage
I'd put all of this into some namespace, so it won't accidentally collide with other usage of the names it defines.
I'd probably also work even a little harder to do something to hid …