Hot answers tagged

8 votes

JVM bytecode instruction struct with serializer & parser

std::variant vs union Avoid blatant memory waste: One of the most common ways i saw other projects implement their instruction ...
G. Sliepen's user avatar
  • 50.3k
6 votes

JVM bytecode instruction struct with serializer & parser

Some style critique from me (the principles seem sound). Since the standard headers are independent of each other, we can include them in a consistent order. I prefer alphabetical, but you could ...
Toby Speight's user avatar
6 votes

Program that inputs the number of days in January, (C++ beginner) (from 1 to 31) (separ. at tens), and outputs #'s written out

Not a bad start. Since the program logic does what it does very cleanly, the only real tips I have are about formatting. It’s customary, and a good idea, to indent the body of each of your blocks. ...
Davislor's user avatar
  • 6,321
5 votes

High performance 3 Way Quick Sort Implementation

Library headers We include <cstdio> but never use it. Conversely, we use std::cout but never include ...
Toby Speight's user avatar
5 votes
Accepted

std::chrono compatible clock using CLOCK_MONOTONIC_RAW

The implementation looks correct to me. I do want to address some potential misunderstanding though: Since steady_clock is affected by certain clock adjustments, […...
G. Sliepen's user avatar
  • 50.3k
4 votes
Accepted

C++17 pointer_traits implementation

I tried a little bit your code and seems to work. If you want my opinion (review?) I find the techniques quite arcane. Perhaps it is my C++17 perspective, or maybe that the code you posted needs to be ...
alfC's user avatar
  • 188
4 votes

C++ Minimal CSV parser cut2

The CSV class doesn't have any members to access or manipulate member data, apart from those used when constructing the class. So it probably shouldn't be a class ...
user673679's user avatar
  • 11.6k
4 votes
Accepted

String literals concatenation with support for dynamic strings

Design review Cool. The idea is good; it’s something I could see myself using. The implementation is sound. In general, cool. I like your requirements, except I would strongly recommend moving to C++...
indi's user avatar
  • 10.2k
4 votes
Accepted

Fast OrderBook Implementation

Adding to pacmaninbw's review: There's a hole in struct Order There's a hole between price and ...
G. Sliepen's user avatar
  • 50.3k
4 votes

Fast OrderBook Implementation

General Observations The general impression of the code is that this is a fast and dirty implementation. Take the time you need to design and implement a proper solution. Some things that the code is ...
pacmaninbw's user avatar
  • 23.5k
4 votes
Accepted

Create classes for matrices, including inheritance

Avoid C functions I see you are using printf() in your code. Consider avoiding this and using the C++ way of printing instead. The main disadvantage of ...
G. Sliepen's user avatar
  • 50.3k
4 votes

C++ custom string class implementation

This looks quite good, I see you have thought about most of the corner cases. However, a few were missed: new can throw When you allocate memory with ...
G. Sliepen's user avatar
  • 50.3k
3 votes
Accepted

leetcode 530. In-order traversal of a binary search tree (C++17)

Use std::invoke() to call the visitor Visitor can be anything: a regular function, a lambda, or even a pointer to member ...
G. Sliepen's user avatar
  • 50.3k
3 votes

C++ Minimal CSV parser cut2

In addition to user673679's excellent review I have a couple of points to make. Use Standard Types I have tried compiling this in both Visual Studio 2022 C++ and ...
pacmaninbw's user avatar
  • 23.5k
3 votes

C++, sort integers using knowledge of entire vector

Since this question recently got bumped: The previous answers are great, but can be simplified a bit. As Carsten S suggested, deleting the copy constructor is a good idea. However, you still want the ...
Davislor's user avatar
  • 6,321
3 votes
Accepted

Tiny Network Web Framework / Library in C++

...
rioki's user avatar
  • 462
3 votes

Design decisions for an efficient OrderBook

I have to admit that I struggle to follow this. The code seems quite jumbled, rather than well-organised and clear. The biggest issue I have is with representing everything as arrays of strings, ...
Toby Speight's user avatar
3 votes

OrderBook Implementation - Follow up

There are no include guards for the header. using orderid_t = uint32_t; uint32_t is not defined. I recommend ...
Toby Speight's user avatar
2 votes

C++ Event System - Game Engine

No need for s_callbacks[] You have a vector of pointers to CallbackContainerBase. But to get the index into that, you have ...
G. Sliepen's user avatar
  • 50.3k
2 votes

Comparator aware `flat_set` implementation

Don't inherit from Compare Your flat_set does not have an is-a relationship with Compare. ...
G. Sliepen's user avatar
  • 50.3k
2 votes

Assignment function for Intervals container

Include the correct headers I don't see a need for these headers: ...
Toby Speight's user avatar
2 votes

Chain of Responsibility Pattern using std::any

Manage Your Memory Correctly! At present, you store C-style pointers everywhere, apparently as weak references, but nothing actually owns any of the workers. You create ...
Davislor's user avatar
  • 6,321
2 votes

Chain of Responsibility Pattern using std::any

The chain of responsibility pattern deals with one request not a bunch of requests. Having to deal with Dishes, Inventory, and <...
Ajinkya Kamat's user avatar
2 votes

Tiny Network Web Framework / Library in C++

General Observations First off, nice a Server and Client Library in 1250 lines of code! This review does comment on some code in the repository that is not included in the question. One of the rules ...
pacmaninbw's user avatar
  • 23.5k
2 votes

Class for packing two 4 bit unsigned integer in uint8_t

Make it work like std::vector<bool> Your class shares similarities with std::vector<bool>. I recommend that you make ...
G. Sliepen's user avatar
  • 50.3k
2 votes

Create classes for matrices, including inheritance

After G. Sliepen’s answer, there is not much left to comment on. I’ll point out one simplification that I think is worth while: instead of ...
Cris Luengo's user avatar
  • 5,178
2 votes

std::chrono compatible clock using CLOCK_MONOTONIC_RAW

The source code looks good. Merge to main and ship it. Consider writing test code which highlights observed behavior difference between this and competing time ...
J_H's user avatar
  • 16.6k
2 votes

C++ custom string class implementation

Overview: I found one bug. Your move constructor puts the object into an invalid state, where you can then potentially invoke undefined behavior. You have a small memory leak in the ...
Martin York's user avatar
  • 94.3k
2 votes

C++ custom string class implementation

You Can Add private Member Functions and friend Functions At least, I think you can. That doesn’t change the the public API one ...
Davislor's user avatar
  • 6,321
2 votes

Design decisions for an efficient OrderBook

Create a type for currency Instead of passing currency around as a long long or double, I strongly suggest you create a new type ...
G. Sliepen's user avatar
  • 50.3k

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