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.
28
votes
shared_ptr and FILE for wrapping cstdio (update: also dlfcn.h)
I should start with the fact that I don't entirely agree with the widespread belief that "explicit is better than implicit". I think in this case, it's probably at least as good to have a class that j …
16
votes
STL queue implementation
A few points that nearly jump out at me:
You've implemented it as a linked list of individually allocated nodes. This nearly guarantees poor locality of reference and for small types wastes quite a …
14
votes
Implementation of binary min-heap data structure
Your names. pvt is pretty poor and P is, frankly, quite dismal as names go. I'm still not sure what P is really supposed to mean.
you've used a fixed-size array where it's not really suitable. If you …
13
votes
Accepted
Searching for pseudo-palindromes ("semordnilaps")
I'd try to break some habits, and make others in their places.
One habit to break is using while (!file.eof()) -- it's nearly always a problem (including this time).
In its place, I'd consider initi …
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 …
11
votes
Accepted
Bezier curves of grade n
Just a few comments:
std::vector<Vector2f> make_bezier(const std::vector<Vector2f>& anchors, double accuracy=10000.0)
You're using float for all your other floating point variables. Unless there's …
10
votes
Converting data when output std container via ostream_iterator
It seems to me that if you want to insert an object into a stream, the "right" way to do it is normally to define an operator<< for that type. That goes for strongly typed enums just as much as it doe …
10
votes
Find the closest number to each given number
First point: every time anybody writes code with using namespace std; at global scope, a cute, furry little animal dies a horrible death. You don't want that on your conscience, so you need to stop do …
9
votes
Determine whether one vector is a prefix of the other
Right now your code has quite a bit of repetition--basically three repetitions, for v1 shorter than v2, v2 shorter than v1, and v1/v2 being the same length.
It seems like it would be easier to find t …
8
votes
Accepted
Socket wrapper class
There are at least a few things I think I'd do differently, at any rate.
const int MAX_RECV_LEN = 8096;
const int MAX_MSG_LEN= 1024;
const int PORT_NUM = 1200;
The ALL_CAPS convention was original …
8
votes
Accepted
n-dimensional Euclidean space calculation templates
To reduce redundancy, I'd probably move the check for the inputs being the same size into a function template by itself, and just invoke that from the other three:
template <typename T>
void check_si …
8
votes
Accepted
Binary Search Tree implementation using templates
Exception handling
While it might make sense to handle the bad_alloc exception, the way you've done so is likely to lead to problems. The basic point of exception handling is that it decouples the po …
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 …
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 …
8
votes
Accepted
Find a Value in a Container
Parameters
As a starting point, I'd usually advise against passing bools as parameters--especially passing more than one bool to a particular function. I have better ways to spend my time than memori …