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
4 votes
2 answers
360 views

Given a type, search for an item of that type in a std::tuple

In my project, I want to search for an item of a given type in a std::tuple at compile time. The given type might not be present in the tuple at all, in which case ...
dw218192's user avatar
  • 143
7 votes
4 answers
957 views

Matrix Class Implementation

I have written a minimal matrix class. I would like to utilize the latest C++ features, follow best practices, and utilize multi-threading in some of the operations. I have also setup a GoogleTest ...
Space Gaori's user avatar
2 votes
1 answer
83 views

Logger for a Game Engine

So I'm making a logger for a program and it has 6 levels increasing severity and things I don't think its as memory efficient as it could be but I'm just getting into c++ and memory coding. I feel ...
Xuul's user avatar
  • 23
-2 votes
0 answers
33 views

C++ template function specialisation within class template [closed]

I'm not used to template programming - much more used to inheritence & composition. But in terms of a general solution, I'm using a tiny project to ensure a reasonable approach for using class ...
Konchog's user avatar
  • 183
2 votes
2 answers
46 views

A recursive_minmax Template Function Implementation in C++

This is a follow-up question for A Maximum Function For Various Type Arbitrary Nested Iterable Implementation in C++. Besides the function for finding maximum, I am trying to implement ...
JimmyHu's user avatar
  • 3,996
5 votes
2 answers
185 views

Binary file reader and writer

I want to write a simple binary file reader and writer class. The class below can read or write file. main.cpp read 500 bytes from tmp.bin and copy at the end of ...
unique's user avatar
  • 153
2 votes
1 answer
61 views

A simple threadpool in C++17

Implemented a simple thread pool that executes task asyncly, and returns a simple future you can wait on. Can you please suggest improvements? ...
HeavyIsSpy's user avatar
1 vote
1 answer
46 views

Asynchronous OOP-based networking using the Epic EOS SDK

There is also a limitation from the Epic EOS SDK in the absence of thread safety, all "C" calls can only be made from one thread. And from the thread where the SDK was initialized. Based on ...
Alexovsky's user avatar
0 votes
0 answers
51 views

Is this iterative inorder traversal algorithm well-known?

I was concerned about the approach in Morris traversal algorithm and came up with simpler solution that uses parent pointers in nodes. The constraints were following: Time Complexity: O(n) Space ...
Max's user avatar
  • 1
3 votes
1 answer
66 views

C++ printing library with templates

I was mad C++ did not have support for printing containers. I also could not find a header only library for printing containers so I decided to make my own. My goals were: 1) practicing templates 2) ...
Doruk's user avatar
  • 105
3 votes
1 answer
81 views

Implementing an Object type in C++

I'm currently working through the "Crafting Interpreters" book by Robert Nystrom. He uses Java to implement the visitor pattern in which the visitor functions return the Object type. C++ ...
GoZaddy's user avatar
  • 33
4 votes
2 answers
441 views

Spatial radius search in Boid simulation

I am working on a Boid simulation with 10,000 boids. I've successfully utilized geometry shaders and an array<GLfloat[3], MAX_BOIDS> for vertices to enhance ...
nowox's user avatar
  • 1,017
7 votes
2 answers
2k views

Gaussian elimination algorithm in C++

Given: j-g-h-i=0 a+b-c-j=0 c+i-d-e=0 e+g-f=0 And known: a=10 b=7 d=3 e=2 f=3 j=14 I want to solve this (or similar equations) ...
Tobias Grothe's user avatar
2 votes
1 answer
75 views

Casino Number Guessing Game

I have created a casino number guessing game in C++: ...
kit.kat.code's user avatar
1 vote
1 answer
76 views

Lazy/deferred OOP-based networking using the Epic EOS SDK

For gaming applications, networking looks strange from the point of view of traditional approaches. Much of the game logic is based on "ticks"; Most often this is a mandatory item of ...
Alexovsky's user avatar
3 votes
2 answers
93 views

Terminal Based Game [v2]

this is the second version of the Terminal Based Game I'm working on thanks to @user673679 for the suggestions, I did not implemented everything you said but it was really fun working on your ...
Ellie's user avatar
  • 347
3 votes
1 answer
104 views

C++ implementation of a concurrent queue and of a thread pool

I am working on an implementation of a concurrent_queue<T> and pf a ThreadPool, see beneath. The objectives are CPU ...
EricFlorentNoube's user avatar
2 votes
1 answer
48 views

ReadDirectoryChangesW Improvements

I'm currently using the ReadDirectoryChangesW Function from the Windows API to build a Directory Watcher. The Watcher should monitor a folder for newly added files. ...
Kevin's user avatar
  • 147
2 votes
1 answer
80 views

How to interface a "pull" library with a "push" library using callbacks

I am using a driver that retrieves data from HW (Driver) and a display (Viewer) that will output data to the user. The user calls a trigger function to initiate the getting of data from the Driver. ...
Orange J's user avatar
3 votes
1 answer
103 views

Terminal based game - walking and collecting points

I create a game in the terminal the premise(for now) is walking around a field collecting points marked as $, and avoiding mines marked as !, the player is marked as @ and normal terrain marked as #. ...
Ellie's user avatar
  • 347
3 votes
1 answer
148 views

Re: C++ 4X Game

This post is regarding the revamp of this post/project I did about 8 months ago. I took a lot of the advice from the suggestions provided (thank you by the way), and fixed the project up, so I'm ...
Selisine's user avatar
5 votes
3 answers
2k views

"Rock Paper Scissors" game

I have created a rock paper scissors game in C++. ...
kit.kat.code's user avatar
3 votes
1 answer
86 views

Partial specialization of class template with minimal code duplication

I have a class template that stores an std::optional<T>. A very reduced version of the class template looks like this: ...
joergbrech's user avatar
3 votes
1 answer
89 views

BF Interpreter in C++

Need to clear my brain. BF interpretor in C++. bf.h ...
Martin York's user avatar
  • 94.3k
4 votes
2 answers
344 views

Class for locking shared disk directory

I'm writing an application to sync files between two directories. In order to prevent simultaneous access to the shared directory from several computers, I implemented blocking of the shared directory....
Andrey Epifantsev's user avatar
2 votes
0 answers
37 views

A recursive_fold_right_all Template Function Implementation in C++

This is a follow-up question for A recursive_fold_left_all Template Function Implementation in C++. Besides recursive_fold_left_all function, I am trying to ...
JimmyHu's user avatar
  • 3,996
4 votes
2 answers
127 views

C++ heap allocator using an explicit free list

Description I've written a heap allocator in C++ using an explicit free list for organization. I've also written a series of unit tests and a microbenchmark using Catch2. At time of writing I've ...
pdm's user avatar
  • 307
3 votes
1 answer
70 views

Multi producer/consumer lock-free queue

I would be grateful if you could review my code for a multi producer/consumer lock-free queue in C++. I am mainly after performance improvements, but all input is welcome. ...
Mr. Orange's user avatar
1 vote
2 answers
1k views

Calling fgets() twice

I am a beginner. I have really struggled with fgets() when using the function twice. I am on Windows with VS Code and C++ extension. My test program is working, but it is IMHO lengthy and complicated ...
mortenlund's user avatar
2 votes
1 answer
92 views

Codeforces: Dasha & Nightmares

so I got started with competitive programming about a day ago and I got stuck on the first random question I tried on codeforces. It's called Dasha and Nightmares. Problem Description: The problem ...
st0n3r's user avatar
  • 73
2 votes
1 answer
278 views

Printing the elements of a forward linked list

I'm a sophomore in computer science who's working on a linked list class for his DSA class. I believe this code can be improved, but I'm not sure how because everything got really messy really fast. ...
o_22's user avatar
  • 23
1 vote
1 answer
52 views

Template for making distinct numeric type aliases

I've tried to make a small template for the creation of distinct (incompatible) numerical types. For example both row and column indices are usually represented as the same underlying type. However it ...
Sam Coutteau's user avatar
10 votes
3 answers
2k views

Cumulative grade-point-average calculator in C++

I wrote a simple Cumulative grade-point-average calculator in C++, and would like to ask for advices to improve the code in terms of best practices (efficiency, reliability) in the language. Here's my ...
kit.kat.code's user avatar
-2 votes
1 answer
65 views

Double set to -1 from function does not equal to -1 in comparison [closed]

I use the function trace() to calculate the trace of a matrix. This is not important. But for this specific matrix this value is -1. My variable "trace" is set to this from the function. ...
Lorde213423432e43434's user avatar
2 votes
1 answer
76 views

Basic foundation for a physics engine using SFML and Dear ImGui

I want to create a very basic physics engine in SFML. I also want to be able to control objects using Dear ImGui. So I created this basic foundation. My main problem with it is how I handle rendering ...
pyt4's user avatar
  • 23
2 votes
1 answer
121 views

OrderBook Implementation - Follow up

This is a follow up to my previous implementation: The input is of the format ...
Avengerx9's user avatar
2 votes
1 answer
52 views

Shared_ptr Implementation with Derived class Awareness

Another shared_ptr implementation. My main idea was to write it in a way you could do: ...
KimGiacinto's user avatar
2 votes
2 answers
177 views

Design decisions for an efficient OrderBook

I am designing code for OrderBook based in C++, based on STL library. Note that there is a related question here, however it is more simple - it does not support deletion of orders, and I intend to ...
Avengerx9's user avatar
3 votes
2 answers
162 views

String partial implementation using a vector

I saw few similar solutions, but they all relied on C-style arrays and str utils, so I thought I would write a higher level C++ only implementation with a vector as an exercise. I have not implemented ...
KimGiacinto's user avatar
1 vote
1 answer
78 views

An Updated recursive_reduce_string Template Function Implementation in C++

This is a follow-up question for A recursive_reduce Template Function with Unwrap Level Implementation in C++ and A recursive_reduce_string Template Function Implementation in C++. Considering the ...
JimmyHu's user avatar
  • 3,996
9 votes
4 answers
3k views

Recreating Minesweeper

First, I have to say that this game lacks 5 features that I don't care: Flags Chording Timer Actual mouse movement Good graphics When starting the program, the player is meeted with a "Choose ...
Le_Square's user avatar
1 vote
1 answer
99 views

A recursive_reduce_string Template Function Implementation in C++

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

Tic-tac-toe game for Windows console

I am doing C++ for over a year and this is my game I tried making tic-tac-toe. And it's also my first program that uses multiple source files. main.cpp ...
NikolaTeslaPaga's user avatar
2 votes
1 answer
137 views

Alarm - Timer - Stopwatch with <chrono>

Alarm, timer and stopwatch in the style of the standard library. Important design notes: The accessors do not update internal state, the user is responsible to call ...
demiralp's user avatar
  • 123
2 votes
1 answer
672 views

Little CLI game in C++ with random words

the game is quite simple, you have to constantly guess the letters of a hidden word, but has a limited number of wrong attempts. The word you are looking for should be a random word from Wikipedia. I ...
Tobias Grothe's user avatar
3 votes
1 answer
103 views

IMAP client impementation on State Machine boost-ext/sml

I made IMAP(IMAPS) notifier on boost-ext/sml state machine. There is an opinion that networking is best done on machines. Compile in C++20. Tested on GMail server. Uses karastojko/mailio (and ...
Alexovsky's user avatar
3 votes
1 answer
121 views

C++ two-phase path-compression quick-union union find over indices

This is my first C++ class, implementing union find. I’ve tested the implementation very shoddily by checking that unifying two points connects them, and that works. I did a first draft in Python and ...
schuelermine's user avatar
2 votes
2 answers
149 views

Improved input validation function

A week ago I posted this question and after reading the answers and accepting one I decided to refactor my code quite heavily. I would like to get some feedback on this newer version. The changes No ...
globalturist's user avatar
2 votes
1 answer
283 views

Traveling Salesman Problem for visiting cities

Implement TSP problem using best first algorithm (so it will be backtracking, branch-and-bound, and best-first). Since you are looking for a cycle, the start/finish city is not important. Therefore we ...
Ruiru's user avatar
  • 21
3 votes
0 answers
89 views

Modern OpenGL Context that doesn't rely on CRT

I'm working on a personal OpenGL project. I want my project to not rely on any libraries including CRT. I have absolutely no experience in shipping software and I want to prepare my code for release. ...
Cherestes Radu's user avatar

1
2 3 4 5
188