Questions tagged [c++]

C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. This tag should be used for any question which requires knowledge or expertise with the C++ programming language. This is a general tag which is used for any of the C++ language standards (C++98, C++11, C++17, etc.). The question should identify the compiler being used, the operating system, and which of the C++ standards is being targeted.

Filter by
Sorted by
Tagged with
3 votes
1 answer
110 views

std::list reimplementation for practice

I used cppreference list to implement this simplified std::list. The CXX_STANDARD is 11. My questions are the usual: Is the ...
Abner's user avatar
  • 39
1 vote
0 answers
50 views

Event System in C++ [duplicate]

I am excited to share that I have developed an event system in C++. I have always been passionate about programming and have long aspired to create a low-level game engine solely using C++, OpenGL, ...
Andrei Rost's user avatar
3 votes
2 answers
2k views

Event System using C++

I am excited to share that I have developed an event system in C++. I have always been passionate about programming and have long aspired to create a low-level game engine solely using C++, OpenGL, ...
Andrei Rost's user avatar
1 vote
1 answer
114 views

Corner detect takes long time to run

I am using OpenCV’s findchessboardcornersSB function to find the corners in the image. I am using below code/ header file: ...
Dushyant Patil's user avatar
1 vote
1 answer
95 views

Binary search of 2D matrix

I have written code as below: ...
Szyszka947's user avatar
2 votes
2 answers
508 views

Fast OrderBook Implementation - Follow Up

Following up from: Fast OrderBook Implementation Here is the updated version (I've also implemented some extra functionality) ==> Order.hpp <== ...
jpf's user avatar
  • 63
2 votes
1 answer
198 views

Write Julia struct to a C++ struct

For the following Julia code: ...
dearn44's user avatar
  • 165
5 votes
1 answer
174 views

uint24_t implementation ported to Windows

I coded stuff for an embedded device where int is 24bits. I wanted to port uint24_t and ...
Vortex 2728182818's user avatar
3 votes
2 answers
104 views

Income Tax Calculator using 1913 tax standards

I am a beginner in a class and recently given a problem where I have to design a income tax calculator but using the 1913 tax standards. I was able to get it down I think but I was just wondering if ...
Friedhegg's user avatar
4 votes
2 answers
572 views

Constexpr flat_multimap

About the Reasoning I wrote a flat_multimap because it was slightly more efficient to read/write from disk (contiguous memory block) and because it would keep the logarithmic efficiency from a tree (...
FreezePhoenix's user avatar
4 votes
2 answers
1k views

Fast OrderBook Implementation

I'm creating a simple yet fast OrderBook, that only adds orders and matches them (no cancelling or modifications, etc.). I'm using partial template specialization to reduce branching in the hotpath, ...
jpf's user avatar
  • 63
3 votes
1 answer
129 views

Improving execution time of physics, data acquisition triggering system simulation

Background I'm attempting to write a physics simulation code, one portion of which involves simulating the triggering system of some equipment. The equipment works as follows: environmental noise (...
MomentumEigenstate's user avatar
4 votes
2 answers
166 views

Create classes for matrices, including inheritance

I've been learning C++ on and off, and recently learnt about overloading and templates. I wanted to used these concepts to create classes about matrices using ...
eccentricOrange's user avatar
7 votes
3 answers
184 views

C++ String Class Reimplementation

I started learning C++ about a week ago and I was hoping somebody can critique my code. I decided to implement my own basic String class just for the sake of applying all that I've learned about ...
Janriz Libres's user avatar
6 votes
3 answers
290 views

Unit testing a Linked List implementation in C++

Recently I wanted to use the gtest library to unit test my program but for some reason, it's incredibly hard to make it work and configure (at least for me it was), ...
I_throw_but_dont_catch's user avatar
3 votes
1 answer
810 views

C++ enum to string conversion utility

I needed to find a way to convert a bunch of enums to string for displaying in C++. The two main ways I found when searching was using dark magic macros or voodoo magic template metaprogramming. As I ...
adepierre's user avatar
5 votes
1 answer
88 views

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

Given a binary search tree, the problem requires calculating the minimum absolute difference between any two keys in the tree. Given the binary search property, the minimum difference must be between ...
loonatick's user avatar
  • 153
7 votes
1 answer
93 views

Breadth-first search implementation for finding edge of grid c++

I have implemented a breadth-first search algorithm to find the distance from a point to an edge of a grid. The grid consists of spaces that may have walls between them, effectively blocking certain ...
Andreas Tostrup Christensen's user avatar
7 votes
1 answer
1k views

Pet Shelter in C++

The provided code represents an implementation of a Binary Search Tree (BST) in C++, specifically tailored for a "Pet ...
I_throw_but_dont_catch's user avatar
10 votes
2 answers
3k views

A* algorithm implementation in modern C++

I've written the A* search algorithm in C++. My goal is primarily writing concise and understandable code, while making use of some new features of modern C++ (where appropriate) and having generally ...
Green绿色's user avatar
4 votes
2 answers
499 views

Text-based Tic-Tac-Toe

I am just beginning to learn coding and decided to create a text based tic tac toe board as my first solo C++ project. My goals were as follows: be able to test if there is a winning state on any ...
Alice Aaron-force's user avatar
6 votes
1 answer
199 views

C++ Eigen/Mex function to perform two pagewise convolutions on a 3D matrix with a simple kernel

I am trying to accelerate an algorithm where I am computing a 2D variance of many complex matrices stored as pages of a 3D array in Matlab. My implementation uses a Mex function with the C++ Matlab ...
drakon101's user avatar
  • 181
2 votes
1 answer
91 views

sendmsg() scatter-gather coroutine awaiter, optimized suspending

My attempt at an Awaiter for sending scatter-gather data over an open file descriptor. Tested only on gcc-13.1.1 Micro-optimizing by suspending the coroutine only ...
serafean's user avatar
1 vote
1 answer
249 views

Lock Guard Atomic alternative

I've recently written a Vulkan library for creating 2D applications with ease. The catch was I need std::lock_guard for my window resize event to resize resources ...
FatalSleep's user avatar
8 votes
1 answer
194 views

Lightweight general-purpose graph library in C++

As a personal side project I started building a graph library in C++ (I know, very original). The code is open source, but for the purpose of this question I will provide the relevant details and the ...
Bobray's user avatar
  • 81
3 votes
1 answer
140 views

Implementing The Decorator Design Pattern in C++

I recently tried to implement the decorator design pattern in C++. Here is the code in full: ...
Sc2046's user avatar
  • 33
-1 votes
1 answer
193 views

Copying allocated data into std::map in a smart way [closed]

I come across a problem and I solved it. The solution works but I have some feelings that there is something wrong with my solution/code. To be clear, let's assume that cars on the race track transmit ...
unique's user avatar
  • 153
3 votes
2 answers
82 views

Enhancing a non-multithreaded Circular buffer

Looking to get some feedback on a simple non-multithreaded circular buffer. Ideally, I'd want to have a logic to prevent the data from getting overwritten but couldn't find a reasonable way. For ...
xyf's user avatar
  • 508
1 vote
3 answers
136 views

C++ getline implementation for custom stdlib

I'm writing my own "standard library". It relies on nothing but syscalls, so I've had to make my own implementations of everything, including getline (...
Fuzzy Muffin's user avatar
7 votes
2 answers
273 views

Priority Queue (With raise priority operation) using Vector

Here I have implemented a priority queue, with the addition of the raise_priority (also known as reduce key) operation. The reason I have effectively reimplemented std::priority_queue is because the ...
FreezePhoenix's user avatar
4 votes
3 answers
1k views

O(NlogN) sorting algorithms in C++

The following code is my lab which focused on implementing any 3 known sorting algorithms out there. Since the professor gave us a choice to pick any of them and compare their execution time I chose <...
I_throw_but_dont_catch's user avatar
3 votes
2 answers
128 views

Covid Data Base Hash Map in C++

This is a follow up question to Date Checking in C++ I have these two function prototypes: void CovidDB::add_covid_data(std::string const COVID_FILE) ...
I_throw_but_dont_catch's user avatar
5 votes
1 answer
167 views

Is there a more idiomatic way than this to use template-generic C++23 multidimensional array subscripts?

C++23 is going to add multidimensional array subscript operators to the language, yippee! Alas, I have not yet come across a way to adapt them to types where the number of dimensions is templated, so ...
saxbophone's user avatar
2 votes
2 answers
94 views

For two sequences N and M, display counts of elements n from N below each m from M up to the first n above m

A school's task: There are two sequences n_tab and m_tab. For every element m in m_tab ...
Szyszka947's user avatar
1 vote
1 answer
319 views

Factory pattern with variadic constructor

I have this code for a factory design pattern that will take into account any number of arguments in the constructor. Through a static boolean in the class a ...
user avatar
7 votes
2 answers
2k views

Date Checking in C++

I am working on one of my assignments (Hash Tables) for my Data Structures class(1st year), the assignment focuses on OOP and understanding of Hash Tables. Restrictions: Usage of raw pointers C++11 ...
I_throw_but_dont_catch's user avatar
4 votes
1 answer
174 views

Simple Model of Library, Books, Checkout, Patrons and Fees

This is an exercise I solved in the PPP book in C++. If there's a better way I could have done something, please tell me. (No main() and Date (just year)) Thank you! For context here is the exercise: ...
PhaazeReborn's user avatar
-3 votes
1 answer
78 views

Catching any exception and actually do something with it [closed]

Say I have a framework, which should catch any exceptions raised from user code, and actually do something with it, such as converting it to a return value ...
user877329's user avatar
4 votes
1 answer
160 views

Tokeniser which yields a Range of string views

In my answer to string_view tokenizer function template I suggested that a flexible tokeniser would yield a Range that could be iterated over. This is my implementation of such a tokeniser. ...
Toby Speight's user avatar
  • 74.5k
6 votes
1 answer
332 views

Image stitching using SIFT keypoint descriptor and homography matrix

I have written a code to stitch 2 images using SIFT keypoint descriptor and homography matrix for perspective transform. Are there any areas where code an be improved or optimized? ...
Dushyant Patil's user avatar
5 votes
1 answer
199 views

string_view tokenizer function template

Below is a function template that tokenizes a given std::basic_string_view using a given delimiter and assigns the tokens to a buffer (via a ...
digito_evo's user avatar
2 votes
0 answers
150 views

Point addition on secp256k1. Exploring other alternatives for practical purposes

...
Knm's user avatar
  • 21
1 vote
2 answers
187 views

C++ Unsign 128 Bit Intrinsic Number

Per feed back for this question, I have written an unsigned 128 bit integer for Windows. The class first determines if it is in a 64 bit environment. It only creates the class if it is in a Windows ...
StormCrow's user avatar
  • 369
2 votes
1 answer
2k views

part of a c++ program which mods a game using code injection

https://github.com/speedrun-program/amnesia_load_screen_tool/blob/main/code_injection.cpp https://github.com/speedrun-program/amnesia_load_screen_tool/blob/main/file_helper.h ...
my_stack_exchange_account's user avatar
3 votes
0 answers
131 views

Simple Network Time Server in C++ with improvements from prior code analysis

From code review: OO simple network time server with changes from a previous code inspection and added Windows support I made many changes as per the review comments. The code has been significantly ...
arcomber's user avatar
  • 2,449
14 votes
2 answers
1k views

Arcsine function for a real-time control program

I have been developing control software for a three-phase induction motor. The main task of this C++ code is to control the torque of the motor. In one part of the algorithm (The control algorithm is ...
Steve's user avatar
  • 355
2 votes
1 answer
278 views

Spherical distance (Vincenty distance) between two geographic points [closed]

I am trying to speed up the code of a R function that calculates a Moran's I autocorrelation coefficient from very large distance matrices between geographic points. So I am exploring approaches to ...
Pierre Levoisin's user avatar
1 vote
1 answer
132 views

C++ Dynamic Balancer on a Threadpool

I have a Balancer Class in my project which should dynamically increases/decreases the amount of Worker Thread based on the current amount of Messages which are ...
Kevin's user avatar
  • 147
1 vote
0 answers
67 views

A recursive_reduce Template Function with Unwrap Level Implementation in C++

This is a follow-up question for A recursive_sum Template Function Implementation with Unwrap Level in C++ and A recursive_reduce_all Template Function ...
JimmyHu's user avatar
  • 4,370
2 votes
1 answer
112 views

QuadTree implementation in c++

I'm new on C++ and OOP. I wrote the following QuadTree implementation (I didn't wrote the remove object part yet). please take a look on it and provide feedback, mainly about C++ OOP design, ...
Joseph Hod's user avatar

1
4 5
6
7 8
190