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 ...
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 ...
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. ...
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 ...
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, […...
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 ...
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 ...
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++...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
3
votes
Accepted
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, ...
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
...
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 ...
2
votes
Comparator aware `flat_set` implementation
Don't inherit from Compare
Your flat_set does not have an is-a relationship with Compare. ...
2
votes
Assignment function for Intervals container
Include the correct headers
I don't see a need for these headers:
...
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 ...
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 <...
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 ...
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 ...
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
...
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 ...
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 ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
c++17 × 561c++ × 546
algorithm × 67
beginner × 58
template-meta-programming × 57
programming-challenge × 47
template × 37
performance × 35
reinventing-the-wheel × 32
multithreading × 22
iterator × 21
strings × 19
object-oriented × 17
variadic × 17
c++11 × 16
memory-management × 16
pointers × 14
boost × 12
linked-list × 11
c++14 × 11
collections × 11
parsing × 10
array × 9
game × 9
sorting × 8