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
0
votes
0answers
7 views

Basic 2d graph implementation

I am currently implementing a Graph Vizualizer app and the following code is my graph implementation. ...
-3
votes
0answers
12 views

How do you program object movement from a beginners perspective? [C++] [closed]

I'm a complete beginner and started learning c++, solely for the fact that I used it a bit for some Arduino projects. Recently I started doing some visualization of very basic physics (like harmonic ...
3
votes
2answers
89 views

Prime numbers iterator

I am not familiar with iterators. I am confused with the traits approach and the traditional one. I don't know which one I should use in 2021. I wrote a minimal ...
1
vote
2answers
56 views

2d Grid - Iterating by Rows / Cells - Take #2

Preface Following my first POC version: 2d Grid - Iterating by Rows / Cells I have gained much more understanding, and present A new version A new version is ready, with templates and an attempt at ...
0
votes
2answers
61 views

The bulls and cows game

I have implemented the bulls and cows game in C++. The code: ...
1
vote
0answers
22 views

Replace function for C++

I'm learning regex for c++, and tried to make a simple function. It is very small but I'm satisfied, because this is the first time I managed to pass function as argument. This is a replace function. ...
-2
votes
0answers
20 views

C++ Calendar Alignment [closed]

Here is what it should look like I am having trouble aligning the first day of the month with the right weekday. The calendar is going to be for this year so January first will be on Friday but I cant ...
3
votes
0answers
33 views

Order guaranteed recursive_transform template function implementation with execution policy in C++

This is a follow-up question for A recursive_transform Template Function with Execution Policy, A recursive_transform Template Function Implementation with std::invocable Concept and Execution Policy ...
3
votes
1answer
67 views

Machine Learning Loss Functions In C++

I was looking for C++ versions of the machine learning metrics implemented in Python's sklearn, but they were surprisingly hard to find. I came across a website that had most of the loss functions ...
0
votes
2answers
36 views

Allow caller optional flags for returns

Checking return flags is generally very important. But, when you don't need to based on meeting pre-conditions, the syntax gets unnecessarily ugly. This class allows returning a value with flags that ...
2
votes
1answer
45 views

A Lowest Common Ancestor (LCA) Tree Algorithm

My implementation of the lowest common ancestor (LCA) algorithm for my tree data structure. I selected the non-preprocessed (naïve) implementation for this first implementation. Support for any number ...
2
votes
1answer
51 views

C++ template and inheritance - Generic Sqrt Decomposition

So I tried implementing a easily extendable solution for Sqrt decompostion, I deduced that only identity value, operation and block update logic change and rest of the code is same. So i created 3 ...
4
votes
3answers
128 views

Improving generic A* algorithm performance

Here is my A* algorithm. I tried hard to implement it generically, but come up only with one idea to use lambdas for heuristic and next nodes (neighbours / successors) functions. I know that using ...
0
votes
1answer
57 views

Deleter for Simple Expression Tree in C++

I have created a simple abstract class called expr_node which will serve as a base class for any expression-related nodes. My goal is to create a simple deleter ...
7
votes
1answer
190 views

Custom implementation to provide an immutable range of a container without copying it

I needed to pass a const reference to part of a std::vector without copy. I posted the previous version in my earlier question, thank you for the great support! As ...
2
votes
2answers
67 views

Shunting Yard Calculator - Extended to negative, complex, etc

This project is based off the shunting yard algorithm and has additional features such as negative value parsing. It's like a scientific calculator. I am looking to improve this project by getting rid ...
2
votes
0answers
22 views

SQL (ODBC) bind to C++ classes row-wise (follow-up)

This is follow-up on SQL (ODBC) bind to C++ classes row-wise The main idea behind this code is to minimize the number of ODBC API calls, because profiling shows significant amount of time is spent in ...
14
votes
4answers
1k views

Numerical integration in C++: Newton-Cotes formulas

I have tried my hand with implementing simple quadrature formulas in C++. Definite integral: $$\int_a^b f(x) dx$$ Domain of integration \$[a, b]\$ divided into \$n\$ intervals of equal length \$h = (b ...
2
votes
2answers
78 views

Fractions in C++

I started learning classes and operator overloading in C++. To test my skills I decided to make a Fraction class with all necessary operations. I would appreciate improvements and suggesstions on my ...
2
votes
0answers
27 views

A reuseable reconnecting TCP socket with Asio

I'm using (non-boost) Asio 1.18.1 and C++17. Forgive the boost tag, there wasn't a more specific one. I have a async_connect_with_retry composed asynchronous ...
2
votes
3answers
93 views

Fixed-size memory allocator

I've been trying to implement a simple Boost PMR allocator that has a fixed amount of memory. My first implementation (which can be found here) had undefined behavior and did not handle memory ...
1
vote
2answers
93 views

HackerRank "Array Manipulation" challenge (using Microsoft concurrent extensions)

I've been practising my coding skills because I have an interview coming up. The HackerRank challenge has 16 test cases; the code passes 9 of them and the other 7 time out. If you go to HackerRank ...
0
votes
2answers
35 views

handling different states of a complex gui control

I need to handle different states of a complex GUI control (such as NORMAL, DRAGGING, MARKING, ...). I came upon this idea: ...
2
votes
1answer
63 views

2d Grid - Iterating by Rows / Cells

The feature Here is a Grid class representing a 2d grid. The class will get templated once it reach a satisfactory state. At this time the cells are int values. ...
0
votes
3answers
115 views

Converting whole numbers to binary in C/C++

...
5
votes
2answers
392 views

C++20 Thread Pool

I've implemented a thread pool using C++20. I'm fairly new to concurrently/multi-threaded programming and wanted to work on a project that I could learn from while also getting to know some of the new ...
0
votes
2answers
91 views

Is there a neater, more elegant way to format this output?

I have this code that writes the initial configuration of a simulator I'm writing to stdout. args is an instance of type ...
4
votes
5answers
1k views

C++ AES Encryption Class

I am working with OpenSSL and writing an AES256 encryption module. My knowledge of cybersecurity is not vast and I would like to know whether there are any obvious holes I'm leaving. The intent is for ...
2
votes
1answer
74 views

Gallery template class

I have created a template class Gallery which is intended to be used as a container for objects. I used a private member of type...
-1
votes
1answer
87 views

HOW can I optimize this FFT C++ Code without using external libraries? [closed]

I have this assignment with the goal of improving the performance and execution time of a FFT C++ code without the use of external libraries. The code is as following: ...
3
votes
1answer
91 views

Simple stack based interpreter

This was inspired by the question Passing Programs To A Stack Machine Implemented In C++. I wanted to make it a bit smarter by adding control functions: instruction op1 op2 op3 description ...
5
votes
2answers
441 views

C++ Garbage Collector - Simple Automatic Memory Management

I made a general smart pointer which fixes the problems of loops between std::shared_ptr's. While use is simple, I feel that my code is inefficient and clumsy. Here ...
3
votes
4answers
128 views

Passing Programs To A Stack Machine Implemented In C++

I'm learning C++ by implementing a previous project I did in Python. This is a simple stack machine which evaluates mathematical expressions, e.g. pow(9, 12). The code to run this on the stack ...
0
votes
1answer
62 views

What do you think about my program and what can I implement to make it more efficient? (ex. runtime wise) [closed]

I'm taking a course and I've just completed a challenge. The program runs well and it does everything I told it to, but I would like suggestions as to what can I implement to make it better (ex. ...
3
votes
1answer
54 views

A counting loop class v2

Rewrite of A simple counting loop class based on feedback: This version adds a step parameter and better iterator concept support. Counting is always done in a signed integral, and only integers and ...
2
votes
1answer
85 views

Simple Lagrange interpolation

I wrote a Lagrange polynomial interpolation class. It works fine. At the beginning some definitions: $$ \begin{align} &nodes:\qquad x_0, \dots, x_n \\ &values:\qquad f(x_0), \dots, f(x_n) \\ &...
1
vote
2answers
105 views

Card deck for Blackjack in an OOP style [closed]

So far I have made a class called Deck, to create and shuffle a deck of cards, and a class called Player, which I want to use to create the gambler and the dealer. My Player class inherits from the ...
6
votes
2answers
290 views

Writing a C++ Matrix class

I am refreshing my C++ programming skills, and I'm currently reading the book C++ 17 by Ivor Horton. The idea is to code some naive implementations of numerical algorithms (Root finding, solving a ...
0
votes
1answer
54 views

A simple counting loop class

EDIT: Updated version available here: A counting loop class v2 Ranges (C++20) aren't quite ready, so until then, I needed a reliable counting loop class that ​works fairly well to replace the old-...
1
vote
1answer
45 views

A possible implementation of std::rotate

I've implemented this rotate_ algorithm mimicking STL's : The algorithm left-shifts all the elements n times where n is the distance between the first element and the axis (middle): ...
2
votes
1answer
39 views

A proxy class as a generic replacement for getters and setters v2

Have you ever written proxy objects, instead of using a setter and a getter method? In that case, I'm interested in your opinion on the following design for a templated proxy. This is a second version,...
3
votes
2answers
130 views

Creating large arrays using limited amount of RAM

This is partially inspired by this question I have started creating an example to show how to keep certain parts of the array on disk and came up with the following: ...
3
votes
1answer
43 views

libsvm++ : Rewritten libsvm in newer C++

The most famous library for Support Vector Machine (SVM) algorithm is libsvm (https://github.com/cjlin1/libsvm/), but I felt that its code style is too old, I rewrote in newer C++ as a hobby project. ...
6
votes
2answers
528 views

Find all possible ways a rook can move, C++ version

This inspired by this C# question The basics is to calculate the total number of paths that a rook can take without revisiting a square to move to a diagonally opposite position. I tried to throw ...
0
votes
1answer
34 views

Stream that computes running median value

I was solving a DSA question, running median in a stream. And I decided to design my own stream class with additional features. ...
1
vote
1answer
71 views

BigByteList with a managed wrapper

I am a novice when it comes to C++ (as well as C++/CLI). I am trying to write a minimal 64-bit implementation of a List in C++ (using unsigned __int64 as the index ...
3
votes
1answer
57 views

Real time histogram using multithreading (Qt + Qwt)

I'm writing a GUI for different VME modules (electronics). There are several of them which are used for the data acquisition. For example, an ADC produces the digitized maximum voltage on its input. ...
2
votes
4answers
113 views

Single-linked-list in C++ with iterators

I'm implementing a single linked list as close as it could be to std::forward_list. I would welcome a review and also more suggestions on what to test additionally. ...
1
vote
2answers
53 views

Implementing std::format - Part 3

This is a follow-up to this question. Here I’m trying to do something useful with the format specifier. I guess I should have started with width and ...
4
votes
1answer
73 views

C++ : Allocator for fixed size object

I'm reading "Modern C++ Design" (A. Alexandrescu, 2002). The author said "the standard memory allocator is awful for small objects", but it has been two decades after the book has ...

1
2 3 4 5
173