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
1 vote
0 answers
64 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
  • 3,996
2 votes
1 answer
98 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
6 votes
2 answers
226 views

ds - A directory switcher via tags in Windows command line

I have this repository. The idea is that there is a file tags sitting in the users home directory, and which contains the tag declarations of the format ...
coderodde's user avatar
  • 27k
4 votes
0 answers
48 views

Variadic pack class providing operations over types without constructing objects of those types

Sometimes I find I want to call a function passing each of a set of types as a template parameter, but without needing to construct an object of those types. I also may want to do this in multiple ...
John Ilacqua's user avatar
4 votes
1 answer
94 views

Custom binary file format serializer

I am creating a binary file format to store a series of vectors alongside some metadata. The vectors will be stored at the start of the file which will have a predetermined size, and the metadata ...
dearn44's user avatar
  • 165
3 votes
1 answer
64 views

Access integer field in network packet

I see three complexities in accessing (reading/writing) integer field in network packet. Handle endianness. Integer in network packet is big-endian (BE). The host may be either big-endian or little-...
Lingxi's user avatar
  • 818
4 votes
2 answers
1k views

Multi-threading Class in C++

I wrote a C++ class which can take a vector of functions and their respective arguments and execute them in parallel and return a vector of results from its respective functions. ...
Darth-CodeX's user avatar
3 votes
2 answers
256 views

Search function using SIMD

I wrote a search function, similar to std::find, that uses SIMD instructions. Since I am new to SIMD, I would appreciate comments on other SIMD instructions I have ...
builtin.ctz's user avatar
2 votes
1 answer
105 views

Any amount bits integer

This class is meant to work exactly as an unsigned integer should work, but it limits the value based on a set amount of bits. ...
RhinoRunner's user avatar
2 votes
2 answers
268 views

Code for asynchronous data stream processing with multistage pipelines

I am trying to write some code for processing streams of asynchronous data from multiple sources (Producer Nodes), process them ...
Haaput's user avatar
  • 23
3 votes
1 answer
82 views

Winsock code for lockstep RTS game

Summary This is my core networking code for the lockstep RTS game that I am creating. Clients connect to a relay server via a TCP socket, and any packets sent to the relay server are forwarded to all ...
Dan's user avatar
  • 341
2 votes
1 answer
119 views

Binary (de)serialization library for c++

A while ago I posted the code for this library I'm working on, and have refactored the code quite a bit ever since. I would appreciate any feedback in regards to what I have so far to see what can I ...
Nitram's user avatar
  • 55
2 votes
1 answer
139 views

A recursive_reduce_all Template Function Implementation in C++

This is a follow-up question for A recursive_sum Template Function Implementation with Unwrap Level in C++ and A recursive_unwrap_type_t Struct Implementation in C++. Considering the answer provided ...
JimmyHu's user avatar
  • 3,996
3 votes
1 answer
74 views

Find a solution to a puzzle with tile squares

I wrote a C++ program to find the solution to a puzzle board (a custom puzzle from my school). The puzzle board is made from squares - tiles. On the different tile middle, side or corner there are ...
weekintas's user avatar
6 votes
1 answer
371 views

Event manager for games written in C++17

This is a single header event manager that I'm using in my game. Disclaimer I ripped everything from these lovely people: https://austinmorlan.com/posts/entity_component_system/ C++ Event System - ...
Burning Flemingo's user avatar
6 votes
1 answer
387 views

Synchonizing queue with mutex

I am trying to syncronize the queue between threads using mutex. I have 2 mil random integers in input.txt file. Main thread reads integers then puts them in queue. Other threads are simultaneously ...
EternalLlama's user avatar
2 votes
3 answers
118 views

Convert integer A to integer B using three operations any number of times

You are given a, b and c. You need to convert a to b. You can perform following operations: Multiply a by c Decrease a by 2 Decrease a by 1 You can perform these operations in any order and any ...
Om Londhe's user avatar
2 votes
1 answer
162 views

Pre-calculate attacks in a chess game

I'm writing (or at least trying to write) a chess engine in C++. This is the first time I write code in C++, and I use this project to practice. Anyway, I'm following the general guidelines of a ...
BarAmber's user avatar
  • 105
1 vote
1 answer
145 views

Large file log parser with less memory footprint

This is a variation of an interesting problem I am currently dealing with. We have a large input file which is being continuously written (size: 10-20G). We need to write a log filter which reads ...
Rohith Uppala's user avatar
-2 votes
1 answer
115 views

Rubik's cube with simulated annealing [closed]

I wanted to write a c++ program to solve a 3x3 rubik's cube using algorithm named simulated annealing, but failed at it. This idea appeared when I watched this: https://www.youtube.com/watch?v=...
Topperoo's user avatar
1 vote
0 answers
70 views

A recursive_unwrap_type_t Struct Implementation in C++

This is a follow-up question for A recursive_sum Template Function Implementation with Unwrap Level in C++. As G. Sliepen's answer mentioned, I am trying to implement a recursive struct for retrieve ...
JimmyHu's user avatar
  • 3,996
4 votes
1 answer
84 views

Remove smiles from string in-place

I have a coding task. Remove smiles from string in-place. Smile is a set of characters starting from ':' and ending with one or more brackets ')' or one or more brackets '(' Example ...
mascai's user avatar
  • 397
6 votes
1 answer
611 views

Simple, fool-proof pattern to execute tasks in parallel

Assume I have a type task_info that stores the task-specific data needed to execute the task. A std::vector of those is built ...
Bolpat's user avatar
  • 163
3 votes
2 answers
241 views

atomic spinlock mutex class

This here is the follow-up to this question. I was recommended to implement a Lockable type (similar to std::mutex) that can work with ...
digito_evo's user avatar
2 votes
1 answer
122 views

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

This is a follow-up question for A Summation Function For Various Type Arbitrary Nested Iterable Implementation in C++ and A recursive_transform_view Template Function Implementation. In the previous ...
JimmyHu's user avatar
  • 3,996
8 votes
3 answers
2k views

Basic RAII spinlock class

I have written the following class that acts as a simple lock for mutual exclusion: ...
digito_evo's user avatar
5 votes
1 answer
270 views

OO simple network time server with changes from a previous code inspection and added Windows support

I put up my SNTP Server code for review here: SNTPv4 server based on rfc 4330 in C++ a fortnight ago and since then I have made changes as per code review comments and also added support for Windows, ...
arcomber's user avatar
  • 2,449
3 votes
2 answers
92 views

text format solution

A firm gave me a small take home assignment which asks you to implement text formatter. Given some text which only contains alphanumerics and spaces (only one space between words), we should align it ...
Rohith Uppala's user avatar
4 votes
1 answer
205 views

Tic Tac Toe console game in c++

For learning purposes i wrote a Tic Tac Toe game in object oriented manner. I have question about storing players in game class - Players(cpu and human) are derived from virtual class players and ...
Paweł's user avatar
  • 43
6 votes
2 answers
150 views

C++ Arbitrary Precision Whole Number Class

The class below implements an arbitrarily sized whole number C++ class. It is wrapped around a bitvector class, which does most the binary heavy lifting. The basic ...
StormCrow's user avatar
  • 369
2 votes
0 answers
38 views

2nd Update Per Feedback - C++ Binary Mathematics Class

Per feedback from here, below is the updated bitvector class. The class was renamed from binary_register to ...
StormCrow's user avatar
  • 369
4 votes
1 answer
59 views

Updated Per Feedback - C++ Binary Mathematics Class

Below is the updated binary mathematics class from the feedback provided here. It was decided that the project should simply be written with an expectation of using C++20 as the minimum version to use....
StormCrow's user avatar
  • 369
5 votes
1 answer
323 views

Port Node and TreeBuilder from Python to C++

I am trying to port a TreeBuilder Python class to C++, keeping the structure as close as possible to the original. Here is a simplified Python version: https://onlinegdb.com/I4dg0hCtg The purpose of ...
Paolo's user avatar
  • 63
6 votes
1 answer
656 views

C++ Binary Mathematics Class

I am working on an arbitrary math lib. Below is a class I use to handle the binary mathematics needed for the library. The class is quite simple. All it does is wrap around a vector of any unsigned ...
StormCrow's user avatar
  • 369
5 votes
1 answer
164 views

A simple Image class utilizing the XTensor library

I've been teaching myself C++, and I recently created a simple Image class that makes use of the XTensor library. With my Image ...
Lion Lai's user avatar
  • 297
-3 votes
1 answer
153 views

std::optional<std::size_t> correct values comparison [closed]

I need to compare two std::optional<std::size_t> variables, considering all possible cases(both std::nullopt or one of ...
Hardwired's user avatar
1 vote
2 answers
244 views

Count the number of ways N queens can be placed on an N✕N chess board

The n-queens puzzle is the problem of placing n queens on an n✕n chessboard such that no two queens attack each other. Given an integer n, this code returns the number of distinct solutions to the n-...
Darnoc Eloc's user avatar
1 vote
1 answer
232 views

Progress bar for reading a file

I have written this class which displays a progress bar reading from the file. In what possible ways could I have gone wrong with this definition? And can somebody suggest what wrongs I am committing ...
Syed Shuja Zaidi P19PH007's user avatar
4 votes
3 answers
2k views

Custom array class in C++

I wrote a custom array class in C++ to suit my personal use case. The main important rule in this project is that no unassigned element is allowed between 2 assigned elements; please review for ...
machine_1's user avatar
  • 519
7 votes
2 answers
2k views

C++ Thread Pool with suspend functionality,

This implementation of thread pool that includes support for suspend functionality, which is necessary for refreshing reference data periodically. I would appreciate your review to ensure that there ...
G. Nass's user avatar
  • 133
6 votes
2 answers
1k views

C++ Thread Pool Implementation using Lock Free Queue

Topic: C++ Implementation of Lock-Free Queue and ThreadPool classes In a project I'm currently working on, I need the implementation of ThreadPool along with a thread-safe queue. I've tried ...
andylvua's user avatar
  • 215
10 votes
1 answer
977 views

Implementing a `concat` range view using C++ std::ranges

The code below is my first attempt to create a concat "range adapter" using C++20 ranges. It compiles and runs with the latest Clang. The little test ...
Rob N's user avatar
  • 201
6 votes
1 answer
144 views

SNTPv4 server based on rfc 4330 in C++

Please review my SNTPv4 server based on rfc 4330 I tested running 3 instances of ntp-check.exe from Galleon systems and 1 instance of Microsoft w32tm - w32tm /stripchart /computer: No crash! This is a ...
arcomber's user avatar
  • 2,449
6 votes
1 answer
134 views

General bytes to number converter (c++)

I've written a bytes to number converter for cpp similar to the python int.from_bytes. It does not make any assumptions on: The endianness of the input buffer The ...
Sam Coutteau's user avatar
1 vote
1 answer
245 views

A CUDA compatible Vector class

Please review the following CUDA-compatible Vector class in C++. ...
user366312's user avatar
5 votes
2 answers
2k views

Deserialize bytes from the network into a struct

I want to deserialize bytes coming from the network to a struct. The bytes come in big-endian order (BE) and my computer is using little-endian order (LE). I'd like your advice concerning in order: ...
Ludovic Kuty's user avatar
5 votes
1 answer
875 views

Monad object in C++

Have I defined a Monad object for C++? Below is a class called var which I created years ago to implement a lambda calculus like interpreter in C++. The class ...
StormCrow's user avatar
  • 369
-4 votes
1 answer
79 views

any bits unsigned integer [closed]

This is a class that acts as an unsigned integer with a variable amount of bits. ...
RhinoRunner's user avatar
7 votes
2 answers
437 views

Arduino library to simplify differential drive robots

I've written code for an Arduino library to abstract away some of the underlying logic in a particular way of moving robots. Code is posted after explanations. I'm not assuming a high degree of ...
eccentricOrange's user avatar
5 votes
1 answer
130 views

A parse function for text line with fields separated by a comma with the known number and their type, simplified version

simplifying this question, taking most of the comment into considerations, I ended up with this version, looking for some feedback ...
G. Nass's user avatar
  • 133

1
3 4
5
6 7
188