Skip to main content
16 votes
Accepted

Processing XYZ data from a large file

There are a number of things that may help you improve your program. Don't abuse using namespace std Putting ...
Edward's user avatar
  • 67.2k
15 votes

FizzBuzz, ’17-style

You're using cout without namespace qualifier which should not work. Personally I think typing std::string is better than ...
yuri's user avatar
  • 4,548
15 votes

FizzBuzz, ’17-style

It looks pretty good, but I think there are some small improvements to be made here. Spell out namespace The using std::string; isn't really particularly useful ...
Edward's user avatar
  • 67.2k
12 votes

Filter out elements from std::vector

You're essentially copying copy_if with some additional debug messages. One can rewrite your code with ...
Zeta's user avatar
  • 19.7k
11 votes

Processing XYZ data from a large file

Well, lets start from the CodeReview: Since this is not really a library, I will omit my typical "Make it easy to use correctly, hard to use incorrectly", but it is still important thing to ...
Incomputable's user avatar
  • 9,722
10 votes
Accepted

Random Number Generator with Loads of Useless(-ish) Features

First impressions I enjoyed reading this code. It's logically laid out (even the includes are alphabetical, so I can check at a glance), and I never felt like I was lost in the code. I do prefer my <...
Toby Speight's user avatar
  • 88.3k
9 votes

FizzBuzz, ’17-style

Be mindful of future enhancements (code always gets more complex over time) and localization. Your method assumes a very narrow range of future enhancements. You'll have trouble in the following ...
Winston Ewert's user avatar
9 votes
Accepted

Connect to telnet server

Ephemeris::Ephemeris() { } No need for a constructor if it does nothing. ...
Toby Speight's user avatar
  • 88.3k
8 votes

Processing XYZ data from a large file

Suggestion 1: Don't split the lines I don't see the need for splitting each line into tokens and extracting the numbers from each token. You can extract all the numbers from a line by using a ...
R Sahu's user avatar
  • 3,572
8 votes

FizzBuzz, ’17-style

Here are some more things that bother me a little (adding to what yuri already wrote in their answer): Design Ugh, globals Globals are bad. They introduce hidden state that the execution of your ...
Ben Steffan's user avatar
  • 5,333
8 votes
Accepted

A Matrix Library in C++;

using namespace std; Never do that; certainly not in a header - that inflicts the harm onto every source file that includes the header. Prefer to include your own ...
Toby Speight's user avatar
  • 88.3k
7 votes

Processing XYZ data from a large file

class XYZCoordinate{ public: int x; int y; float z; XYZCoordinate(int X, int Y, float Z){ x = X; y = Y; z = Z; } }; Integrate a ...
Snowhawk's user avatar
  • 6,770
6 votes

Printing a C++ struct

It only works for some structs Your print_struct() function only works for types that support aggregate initialization; it's not a perfect generic solution for ...
G. Sliepen's user avatar
  • 69.3k
5 votes

Compile-time Lagrange polynomials in C++

struct evaluate ⋯ Compile-time computation is much easier today using constexpr! Rather than going for a pre-2014 TMP library,...
JDługosz's user avatar
  • 11.7k
5 votes

Processing XYZ data from a large file

Preallocate space in your vector for storage of your points, with .reserve(size). Without preallocation, ...
AJNeufeld's user avatar
  • 35.3k
5 votes

Filter out elements from std::vector

Pointless typedef In C, it's fairly common to have a typedef like this: ...
Jerry Coffin's user avatar
  • 34.1k
5 votes

Calculate the crc32 of the contents of a file using boost

I've got little to add to Martin Yorks great answer. I also think the loop approach is the better one, since it limits the amout of memory used for bigger files. However, I found a little mistake in ...
Jörn Schellhaas's user avatar
5 votes
Accepted

Automatic Differentiation with C++ Header-Only Library

Does RealType have to be a type of floating point number (at least at the root level)? If so, perhaps this should be enforced using ...
user673679's user avatar
  • 12.2k
5 votes
Accepted

Using Boost.Spirit to transform expression to AST

I'll narrate this in the order I "discover" your code. Then I'll present some tweaks which I think mattered the most in the end. I'm liking a lot of what you've done. A few names could (...
sehe's user avatar
  • 1,398
5 votes
Accepted

Photo Reduction Tool version 2 - Possible reinvention of the wheel

Be consistent You are not very consistent with how you name things. Here is a non-exhaustive list of inconsistencies: FileCtrlValues: you use the abbreviation <...
G. Sliepen's user avatar
  • 69.3k
5 votes
Accepted

Command Line Photo Size Reduction Tool - version 3

Pre-review check Before I review anything, I want to make sure I understand what the intention of this code is. So, with the way your program is currently set up, you have three program options that ...
indi's user avatar
  • 16.5k
4 votes

Pattern for writing a generic string transformation function

Look at Boost.Range. Your first point drives most of the rest of the concerns. Write your template function to take a Range. You can pass it a C string literal, a std::string, an array, vector, or ...
JDługosz's user avatar
  • 11.7k
4 votes
Accepted

SCOPE_EXIT implementation

Move semantics: The makeScopeGuard() function accepts the lambda by r-value ref; but passes a normal ref to the constructor of ...
Loki Astari's user avatar
  • 97.7k
4 votes
Accepted

Compile-time Lagrange polynomials in C++

I don't want the whole function to be constexpr. I'd like to do without a for loop, but still supply the x at which to evaluate at runtime. About constexpr ...
papagaga's user avatar
  • 5,817
4 votes

Run an asynchronous child process with timeout

I'm still getting used to Boost::Process, so maybe I've got this wrong. However, do you really need the c.wait() after ...
user3224083's user avatar
4 votes
Accepted

C++ observer pattern via boost.signals2

Boost.Signals2 is a thread-safe library. It uses mutex locking internally. There are some caveats, as explained in this article: Almost all classes provided by Boost.Signals2 are thread safe and can ...
Cinder Biscuits's user avatar
4 votes

Fibonacci and Lucas sequence generator using Boost and GMP

I recommend using more compiler warnings - they can highlight issues such as ...
Toby Speight's user avatar
  • 88.3k
4 votes
Accepted

Non-nested std::deque and std::list Generator Function for arithmetic_mean Function Testing in C++

Make the desired container type a template parameter You are duplicating a lot of code, when the only thing that changes is the type of container that your are returning. You should make the container ...
G. Sliepen's user avatar
  • 69.3k
4 votes
Accepted

A Various Container Type Arbitrary Nested Iterable Generator Function Implementation in C++

Template vs. function parameters Template parameters should normally be used for things that affect the type of the result, but not for other things. The template parameter ...
G. Sliepen's user avatar
  • 69.3k
4 votes
Accepted

Nested std::deque and std::vector Type Test Cases for recursive_transform Template Function in C++

You are correct in your intuition that this isn’t really the best way to do this with Boost.Test. In fact, Boost.Test has about a half-dozen better ways to handle this, but I’ll focus on the one that ...
indi's user avatar
  • 16.5k

Only top scored, non community-wiki answers of a minimum length are eligible