r/Cplusplus

Matching engine performance challenge.
▲ 11 r/Cplusplus+1 crossposts

Matching engine performance challenge.

Along with our recent publication: "The World's Fastest Matching Engine Algorithm" on arXiv — and we're cordially inviting the HFT community to try to prove it wrong.

Paper: https://arxiv.org/abs/2606.01183

The claim, briefly: a single CPU core sustains ~32 million orders/second per symbol at sub-microsecond tail latency under sustained multi-million-message micro-bursts — 5–11× faster than the best open-source matching engines on the same hardware. On a single 96-core instance (~$1,630/month), it reaches ~640 million messages/second across 10,000 symbols.

In US equities, where marketable flow routes to whoever holds the NBBO, matching throughput isn't a vanity metric — it's the exchange's market share. Which is exactly why a claim like this deserves to be tested rather than taken on faith.

So we've opened the test, even though our engine itself stays proprietary. What's public is the harness: the deterministic workload generator, the methodology, the byte-level reference outputs, and the adapters for the open-source engines we benchmark against. With it, you can put your own engine through the same harness on your own hardware and see how it stacks up against the figures above.

The harness also includes adapters for several widely-cited open-source engines as well as the engines that claim high performance numbers (> 10 M/s, with some engines claiming > 100 M/s), so you can see how each measures under this workload — set against the figures their projects publish. The full comparison is in the repo.

If your engine matches or beats our figures, we'd love to hear it. If you think the methodology is unfair, we want to hear that too.

No hand-waving: an open workload, an open methodology, and baselines anyone can rerun — so you can judge the comparison for yourself and find out exactly where your own engine lands.

Harness: https://github.com/flash1-dev/matching-engine-benchmark

Run it, push on it, and tell us what you find — we'll be in the comments, glad to compare notes.

u/East_Cantaloupe4925 — 13 hours ago
▲ 19 r/Cplusplus+2 crossposts

Pixel Editor UI

Just a quick update on the ongoing development of my new Pixel Art Editor that is using my custom c++ GUI framework.

The screenshot shows 2 visible and scrollable layers (one RGB reference image and one smaller indexed palette image) with the indexed palette in mid edit!

I'm currently working on the layer and timeline system and have a full scrollable layer list panel with draggable layers and groups - all with editable names.

Any feedback or questions appreciated.

▲ 3 r/Cplusplus+2 crossposts

Rad-UI released! A new reactive, cross-platform C++20 UI framework

I just released my c++ 20 library for reactive UI development inspired by QML and slint.

I haven't worked on the project for a while and thought it has reached a usable state and wanted to share it.

What is included in the library:

- reactive framework with `Property<T>` type. Currently the reactive types are tied to the library internals and not for general use.

- Memory is managed for a great extent. You will never have to use `delete` or `new` except in the constructor of `std::unique_ptr<T>` if `std::make_unique` does not suffice.

- Mouse and Keyboard and Clipboard support.

- Smooth, powerful and easy to use animations.

- GPU rendering using direct2d on Windows and skia for anything else.

- High DPI support and frames are updated only when something changes.

- Complex text rendering using DirectWrite and skia paragraph supporting complex formatting and mixed RTL and LTR languages. Loading fonts from system, memory and files is supported.

- Support for Windows and X11 (and XWayland) with plans to support Wayland natively, macos and android.

- Ready to use UI components from material3 and fluent2 although most components are not implemented yet.

- Model View Delegate framework: ListView, TableView and TreeView along with basic models and delegates.

- Multiple top-level windows, modal windows and popups.

- Async, multithreading and networking support is provided through the RAD library.

- Many other things I may have forgotten to mention!

What is not included yet:

Documentation (the biggest thing!), accessibility, internal and external drag and drop, better multi paragraph text support, implement more UI components, embedded resources, translations and localization and a ton of other things.

Demonstration video:
https://youtu.be/QDgY-0hH1gs

I reduced the quality and FPS to reduce the size of the video

github.com
u/JlangDev — 1 day ago
▲ 70 r/Cplusplus+2 crossposts

consteig. How much math can you force the compiler to do at compile time? (a lot)

consteig src

consteig docs

Presented here is a header-only C++ compile-time eigenvalue and eigenvector solver with no dependencies beyond a C++17 compatible compiler (so no stdlib dependency, no .cpp files). I started on this project 6 years ago and only got back into finishing it recently.

Technically this is a "personal project" I suppose but I intend it to be used by other C++ programmers (or math nerds) and I'd consider it "production-quality". So I think a formal post is acceptable.

If you don’t remember (or haven’t encountered) eigenvalues/vectors, eigenvectors are vectors whose directions are unchanged when linear transforms are applied to the system (which makes them special). Eigenvalues are the factors by which an eigenvector is stretched or shrunk (but whose direction remains unchanged); usually this is expressed as matrices in linear algebra. They’re useful for lots of engineering problems.

For a certain class of problems the matrix for which you want to find the eigenvalues/vectors doesn’t change, effectively making the eigenvalues/vectors constants. These are things like state space matrices for LTI systems, roots of a polynomial, structural dynamics, and some graph/network problems. I’ve got some examples in my docs. If you need the eigenvalues/vectors for those in a C++ program, what you do today is either (1) calculate them at run-time using something like Eigen or (2) calculate them in matlab/python and hard-code them into your program. I’ve pushed all of the math for doing that into compile-time using the compiler itself. This means you can define static matrices at compile time, and save the eigenvalues/vectors off as constants in memory without needing to spend any run-time cycles nor to independently track/calculate them with another tool.

Again; I’ve got examples above, but you can use this to do something like specify filter characteristics (sample rate, cut-off frequency, Order, etc...) and at compile time calculate all the digital filter coefficients. So you can end up doing something like:

// 3rd order butterworth with 100Hz cut-off and 1kHz sample rate
static constexpr constfilt::Butterworth&lt;double, 3&gt; b(100.0, 1000.0);

//Call at 1kHz at run-time
b(new_sample);

And you never need to use python nor matlab to figure out what those coefficients are. I’ve also got another less-polished / less-tested / less-complete compile-time library called constfilt now that does exactly that. consteig available on GitHub and in vcpkg; I’m working on Conan :).

u/human_or_coffee — 5 days ago

I Rewrote My Scanner After Your Feedback and the Difference Is Huge

A few days ago I shared my C++ disk analyzer here and got a lot of feedback about scan speed.

The biggest suggestion was looking into NTFS MFT-based scanning instead of traditional filesystem traversal.

After implementing MFT scanning, the same 512GB SSD that previously took around 2 minutes to scan now completes in roughly 5-10 seconds.

Still a lot of work left to do, but this is probably the biggest performance improvement I've made so far.

GitHub: https://github.com/Gurates/ByteMap
Previous Post: previous post

u/Relevant_Tax_6814 — 4 days ago

Why did it write this on its own??

so i am learning cpp ( from learncpp.com) and this was supposed to be my first "program"
and after i installed clion and installed xcrun
i created a new project called hello world and it wrote the project on its own
did that happen due to it being in the standard library or something??

and I also have some other queries?
for eg : why do these files always show up beneath the main project ?( image 3)
when i installed c lion these program /codes were written there already ( image 2)
os mac silicon

u/Technical-quack-69 — 5 days ago

Tiny C++20/OpenGL game project - looking for feedback on structure and CMake

I made a tiny single-player Agar.io-like game in C++20 + OpenGL.

Repo:
https://github.com/ShortKedr/ugar-io-opengl

It was mostly a personal experiment: I usually work with engines, so I wanted to make a very small game directly with C++, OpenGL, GLFW, and CMake.

Now I want to clean it up into a nicer open-source project and would appreciate C++ focused feedback.

Things I’m curious about:

  • Is the code structure easy to follow?
  • Is the separation between game logic, rendering, and input reasonable?
  • Is the CMake setup acceptable for a small project?
  • Are there any obvious C++ smells or design decisions I should fix early?
  • What would make the repo more pleasant to read or contribute to?

The project is intentionally small. I’m not presenting it as an engine or a finished game, just as a small C++/OpenGL project that I want to improve based on real feedback.

Roasts are welcome, but useful roasts are even better.

u/Mr_ShortKedr — 5 days ago
▲ 14 r/Cplusplus+1 crossposts

Small Terminal Tetris Game

Hey guys, I have been going through learncpp and paused at the array section because I thought it would be a good place to stop and make a small project to reinforce the concepts that I have read about up to this point. I made a small tetris game and want some feedback on the quality of the code. I am pretty inexperienced in things like code quality and readability as I am a beginner and wanted some critique. It is a naive implementation and I am just using a 2D array to represent the board as performance really isn't my primary concern. All core mechanics such as board collisions, complete lines, and game end are present but there is only one piece. I added only one of the 7 pieces because I solved the problem I was trying to solve and adding the other pieces is a trivial change. The github of the project is linked below. The binary of the project that is in the releases section was built on macos.

https://github.com/Anant-raj2/tetris

u/Ok-Design6386 — 5 days ago
▲ 101 r/Cplusplus

The Story of C++: The World's Most Consequential Programming Language | The Official Story

https://www.youtube.com/watch?v=lI7tMxzSJ7w

This is the story of C++, one of the world’s most widely-used and consequential programming languages. C++ divides opinion, resists replacement, and has outlasted almost everything built to supersede it.

C++ The Documentary traces the full arc, from its origins in the corridors of Bell Labs to the global community that shapes it today.

Featuring the people who built it, extended it, argued over it, and refused to let it die.

u/freaxje — 6 days ago

Facing issues setting up c lion on mac ( please help)

I have started to learn cpp using learncpp and the moment the ide choice came I settled on c lion

But after installation I saw that learncpp had the new project opening tutorial in visual studio ( I knew that he wouldn't use c lion) but I thought the process of starting a new project would be similar . So after I clicked on new project it didn't show me solution folder and some code appeared in background, all sorts of folders appeared under project and also a pop up came regarding python3 i denied installing it ( because I thought why would cpp need python) but when the xcrun popup came , I searched it on Google and gemini recommended to install it , so I did that

But I am confused as the solution folder which contains different projects was either not created in c lion or i don't know where it is . Also i was recommended to install python3 as well but i don't know how to get the pop up , so i uninstalled clion and installed it again but it did not start like last time( no terms and conditions and pop up) just a welcome to clion written in code) and it is also showing 30 days left on trial but I am using it for studying purposes isn't it free for that ??? I will get my college id in a few months ( probably July end) so am I gonna miss out on some student feature and which id should I use to login c lion college or personal?? Some also recommended installing x code for c lion to function???

How can I set up my c lion please help

Edit: it is an apple silicon based macbook pro

reddit.com
u/Technical-quack-69 — 5 days ago
▲ 7 r/Cplusplus+4 crossposts

I developed a small 5G Base Station Configuration Validator as part of a 5G Test Automation project. This tool is designed to support automated radio-level validation in 5G testing

github.com
u/nidalaburaed — 6 days ago
▲ 28 r/Cplusplus+2 crossposts

Exotic CRTP: Enforcing Strict Interfaces Without Friends Using C++23 Explicit Object Parameters

I’ve been experimenting with CRTP and ended up with a variation that enforces a strict interface/implementation boundary without friend declarations. The goal was to eliminate boilerplate I frequently encountered when trying to encapsulate derived class methods.

The key idea is using C++23 explicit object parameters this + a small access wrapper type so implementations can only be called through the interface layer.

That was about two and a half months ago. Since, I’ve taken the time to better understand it and write an article about it, which you can find below. As explained there, I refer to this approach as Exotic CRTP.


Example

// Reference example of the pattern  
// See: https://medium.com/@felixolivierdumas/exotic-crtp-rethinking-static-polymorphism-with-c-23-89f9e75e8ffd

#include &lt;iostream&gt;  
#include &lt;type_traits&gt;  
#include &lt;utility&gt;

namespace exotic {

template&lt;typename From&gt;  
struct crtp_access : From {};

template&lt;typename T&gt;  
constexpr decltype(auto) as_crtp(T&amp;&amp; obj) noexcept {  
    using crtp_access_t = crtp_access&lt;std::remove_cvref_t&lt;T&gt;&gt;;  
    return static_cast&lt;crtp_access_t&amp;&amp;&gt;(obj);  
}

}

struct Base {  
    void interface(this auto&amp;&amp; self) {  
        exotic::as_crtp(self).implementation();  
    }  
};

struct Derived : Base {  
    void implementation(this exotic::crtp_access&lt;Derived&gt; self) {  
        std::cout &lt;&lt; "Derived implementation" &lt;&lt; std::endl;  
    }  
};

int main() {  
    Derived d;

    d.interface(); // perfectly works

    // d.implementation(); -&gt; doesn't work, Derived only allows .interface()  
}  

<details> <summary>Show original explanation</summary>

As many comments have mentioned, I'd like to clarify a few details regarding how the cast works.

Let's get straight to the point; the design is neither safe nor unsafe. Let me explain.

First of all, you need to know that the layout of structs/classes in C++ works as follows: in most ABIs, the Base Subobject of a Derived class (either a vtable pointer if polymorphic, or the complete object otherwise) is placed at the Derived's first address. Subsequently, the Derived's data (object) is placed there. This allows for down/upcasting, for example, because the compiler can simply cut the Derived portion to obtain the base, and vice versa.

This layout is not guaranteed by the standard. As I explained, it works with the vast majority of compilers, but there's no absolute certainty that this is how it’s going to appear. I must also reiterate that what I'm presenting today is closer to experimentation and a proof of concept than a finished product. It's an interesting concept; now all that remains is to develop it further.

So why am I explaining this? Because it's precisely with this mechanism that I can explain what happens during the cast to crtp_access<T>. Indeed, if we look closely at crtp_access<T>, we can see that it's empty. Therefore, if it inherits from any database (non-virtual; the design doesn't work if there's virtual inheritance in the chain), we can agree that its size will be equal to sizeof(T) + sizeof(crtp_access<T>), which is 0. This means that in memory, crtp_access<T> is exactly the same size as T. In addition to being the same size as T, in memory it is literally identical to it.

So, when we cast from T to crtp_access<T>, we are indeed performing an 'unsafe' cast, but it's still OK because it's as if we were casting from T to T. It's hacky, I admit, but I like to have fun and test things out.

So, design-wise, I agree that it's very hacky. However, I stand by my point that it's not unsafe ONLY in this specific case.

Also, thank you for all your comments. I've taken a lot of advice and it's helped me better understand my own design. I still have a lot to learn and I'm working on it every day. It's moments like these, when I spend four hours reanalyzing my pattern, that push me to improve even more!

</details>

UPDATE: I’ve reworked a big portion of the article to respond to the technical questions and feedback from here. It’s a pretty long read, but I’ve put a lot of effort into it, and I think it’s worth it if you’re interested in the topic.


Here’s the link to the article, it’s a long read (about 5,000 words, ~20 minutes), but I think it’s worth it if you’re into the topic: https://medium.com/@felixolivierdumas/exotic-crtp-rethinking-static-polymorphism-with-c-23-89f9e75e8ffd

Also, here’s a GitHub repo for those who would like to suggest improvements or modifications: https://github.com/unrays/exotic-crtp

reddit.com
u/Mysticatly — 8 days ago
▲ 17 r/Cplusplus+1 crossposts

Learning C++ As a complete beginner.

I am learning C++, i have zero experience in programming other than an 8th grade chapter on python. Its been hard, especially breaching the gap between learning and actually building programs.

Any tips and tricks on how to actually get better at creating programs ?

reddit.com
u/m_dhav — 10 days ago

My password system progression

I've been learning when I have time over the last few months and have documented my progress through making the best password system I could think of at the time. They all have issues which I fixed as I learned last one has problems with repeat logins based on how it searches through strings. Quite proud of that idea that I came up with could probably be a bit easier if I convert the letters to numbers or something and put them in an array and then search the array. That could run into rare issues because there's 10 numbers and 26 letters so if someone has their name as z that would make bf unregistrable and numbers would have to either be converted to 222 or something but that would, make bbb, bv and vb like combinations impossible. That way would have also been easier to do which means I don't apply as much, so I didn't do it that way.

You can see where I discovered loops, then realized what I could do with them.

https://preview.redd.it/u5kkfvihk55h1.png?width=548&format=png&auto=webp&s=1f9a315580aff421066eb7cf0b1446b44778b0f7

https://preview.redd.it/gmp6ai74k55h1.png?width=649&format=png&auto=webp&s=b3d2c1f4d3e5d65770eb751554655aed0dcaee2c

https://preview.redd.it/d6m2cp7eg55h1.png?width=766&format=png&auto=webp&s=768bbf56fefc97e9a0c5183bd73eed6311db915a

https://preview.redd.it/s61s2bvhg55h1.png?width=848&format=png&auto=webp&s=ec6d2edfc49b89cc6217755d2f88dc97745df08b

https://preview.redd.it/4u4y501xh55h1.png?width=745&format=png&auto=webp&s=d074fce5f36131d3ed9626f89fc5a4ecbfc6adba

https://preview.redd.it/io6kkh8zh55h1.png?width=820&format=png&auto=webp&s=c927747810a1bfe1dcffd64bb7d8d57e564bc917

https://preview.redd.it/15cdp4p1i55h1.png?width=773&format=png&auto=webp&s=6e49ffd9daca02e1776b1f390bed66393fc5877f

reddit.com
u/WizardFlameYT — 7 days ago
▲ 3 r/Cplusplus+2 crossposts

My first project as a beginner

https://github.com/vadyasha07/Command-Line-Drone-Config-Simulator

Hello everyone!
I've been learning C++ for a few weeks now and just finished my first relatively big project: a Command-Line Drone Configuration Simulator.
Repository link: https://github.com/vadyasha07/Command-Line-Drone-Config-Simulator

What I’ve implemented so far:
Modular Architecture: Split the code into logical modules with separate header (.h) and source (.cpp) files (main, drone, encryption).
State Management: The drone's behavior depends on a set of states (isWork, isFlight, onGround) managed within a custom namespace Drone.
Input Validation: Implemented bulletproof input validation using std::cin.clear() and std::cin.ignore() to prevent infinite loops when a user accidentally enters letters instead of numbers.
Case Insensitivity: Used std::toupper to ensure the menu works seamlessly regardless of whether the user types uppercase or lowercase commands.

I’ve tried my best to follow clean code practices, separate declarations from implementation, and handle edge cases (like a password-protected access panel with limited attempts and proper landing sequences with real-time simulation delays).
As a beginner, I would highly appreciate any feedback, tips, or constructive criticism. Is the project structure solid? Are there any anti-patterns I should avoid in the future?
Thank you in advance! Any advice is gold for me right now.

u/vadyasha07 — 9 days ago
▲ 2 r/Cplusplus+1 crossposts

Looking for a friend to grow together

Hello, I'm a first-year computer science student and I'm currently learning the C programming language, which is based on systems programming. Learning alone is very frustrating because I've experienced quite a few failures since I started. I'd like to find a partner to progress and learn with. The time zone where I live is GMT (UTC+0) and I'm available around 10 PM.

reddit.com
u/Puzzleheaded-Task965 — 8 days ago
▲ 7 r/Cplusplus+1 crossposts

Python bindings for the C++ DataFrame

Grizzlars is Python bindings for the C++ DataFrame with an interface almost identical to Pandas. It is a bit of work in progress. It depends on an older version of C++ DataFrame than the latest release. But it is moving along surely.

github.com
u/hmoein — 9 days ago
▲ 29 r/Cplusplus+1 crossposts

Built a simple Audio Recorder App in C++ using portaudio

Developed a cross-platform command-line audio recorder and player in C++ using PortAudio.

Features:

Record audio from the system default microphone in real-time.

Store multiple recordings in memory and access them by name.

Interactive command-line interface with simple record, play, and stop commands.

Cross-platform audio support through the PortAudio library.

Uses 48 kHz, 16-bit PCM mono audio with low-latency buffer-based processing.

Git:https://github.com/charanHubCommits/Audio-Recorder-CPP

Any feedback, suggestions are welcome!

u/_superuserdo_ — 11 days ago

My first program feels ruined

First program man and it is not even working

I don't know how to solve the problem rn

And ofc I have to write 100 words.

u/shxshwat17 — 11 days ago