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
43 views

Observer pattern written in C++

I just carefully studied the observer pattern. And I wrote a demo snippet to better undertand it. I am not so sure that if it's the right way to define ...
John's user avatar
  • 59
3 votes
1 answer
58 views

Multithread execution times are slow on Ubuntu and fast on Windows

I'm working on a project accelerating the execution of a Genetic Algorithm both on multiple cores and on a GPU. The algorithm is specifically suited for the solution of the Traveling Salesman Problem ...
Pietro Pianigiani's user avatar
-2 votes
0 answers
27 views

C++ and RAII - pass reference in constructor just to be sure that GLFW is initialized [closed]

I'm beginning to work with GLFW and Vulkan and I'm abstracting it on some classes. I'm also trying to enforce the RAII pattern. I want to have a Window class, and during this Window creation I want to ...
Caio Vinícius's user avatar
2 votes
0 answers
57 views

Compute shader based Particle System

I'm experimenting with compute shaders and wrote the particle system. The emit shader now takes particle data from the constant buffer because I don't have randomizing functions implemented yet. That'...
Edziju's user avatar
  • 319
3 votes
1 answer
114 views

initializing a timezone database and getting all timezone names (before main())

I have written the below small program that tries to initialize a tzdb before the main() runs. So once the main function runs, it checks the two global variables (...
digito_evo's user avatar
5 votes
1 answer
467 views

C++ - Find all duplicate files (follow-up)

What's changed since the first version: Instead of hashing each and every file, the sizes of the files are first compared, and if those are equal, the files are then hashed. A more collision resistant ...
Harith's user avatar
  • 5,834
2 votes
0 answers
54 views

Optimizing even more a C++ matrix class with expression templates using variadic templates

I looked at Bowie Owens' cppcon 2019 talk (the slides can be found here) where he shows how to implement a tridiagonal matrix classes using expression templates but without resorting to the CRTP. (It ...
11house's user avatar
  • 21
3 votes
1 answer
274 views

C++ - Find all duplicate files

It requires no explanation, so here's the code. Code: ...
Harith's user avatar
  • 5,834
-1 votes
0 answers
74 views

Simple C++ Program: Enter Golf Scores, Calculate Average, and Display Results using Arrays [closed]

I'm a beginner in C++, and this is an exercise I did after I learned functions. This C++ program prompts the user to input up to 10 golf scores, with an option to exit early. It then calculates and ...
zonkler's user avatar
3 votes
2 answers
90 views

Data Base Management System in C++ mimicking SQL based DBMS's (not for parsing SQL syntax)

I'm building a DBMS similar to SQL based DBMS's (like mySQL for example) currently implemented creating a table and reading from a table. no user input yet implemented for testing I create std::string ...
Ellie's user avatar
  • 549
7 votes
3 answers
2k views

Simple TCP port scanner

I’ve done port scanner program. It works well and accurate, but there is a problem. It’s SUPER slow. That’s how it looks: ...
Eudziro's user avatar
  • 81
2 votes
2 answers
166 views

Dimacs parser written in C++

I am a beginner in C++. I recently wrote a dimacs parser in C++ as a learning exercise. Can you suggest improvements in my code? ...
Sai Charan Marrivada's user avatar
1 vote
0 answers
33 views

recursive_remove_copy_if and recursive_remove_copy Template Functions Implementation with Execution Policy in C++

This is a follow-up question for recursive_remove and recursive_remove_if Template Function with Unwrap Level Implementation in C++. I am trying to implement ...
JimmyHu's user avatar
  • 4,708
6 votes
4 answers
632 views

Alternative control flows to highlight happy-path

Moved from stackoverflow Often when writing code I need to check return values before continuing with the operation. This means that the code is cluttered by control-flow that I don't really care ...
Florian Humblot's user avatar
8 votes
1 answer
264 views

C++ - Lexer for the Monkey Programming Language from the book "Writing An Interpreter In Go"

Below is a C++ version of a lexer for the Monkey programming language, originally written in Go, as presented in the book Writing An Interpreter In Go. LOC: 262. (Excluding the tests.) Language: Copy ...
Harith's user avatar
  • 5,834
7 votes
1 answer
241 views

Multithreading message queue system

For an application I'm developing, I need an system which allows a thread to submit messages to another thread. For this purpose I designed a message queue system with the following features. Any ...
Sam Coutteau's user avatar
1 vote
1 answer
77 views

My C++ implementation of the Factory Pattern

Please review my implementation of the factory pattern; it gives a trivial example. Feel free to point out anything I've missed or any code styling tips. ...
Archie Payne's user avatar
4 votes
1 answer
139 views

Print and compare structure comprising two integers

The question is from: https://www.learncpp.com/cpp-tutorial/member-functions/ Create a struct called IntPair that holds two integers. Add a member function named <...
Harith's user avatar
  • 5,834
5 votes
2 answers
913 views

C++ - Secretary Problem using dynamic programming

I tried using dynamic programming to get a solution to the Secretary Problem. It seems to me it's working with with expected result. I really didn't want to use ...
Nemexia's user avatar
  • 153
1 vote
1 answer
32 views

recursive_remove and recursive_remove_if Template Function with Unwrap Level Implementation in C++

This is a follow-up question for recursive_find and recursive_find_if_not Template Functions Implementation in C++ and A recursive_copy_if Template Function Implementation with Unwrap Level ...
JimmyHu's user avatar
  • 4,708
7 votes
1 answer
162 views

Function composition in the context of data processing pipelines

Prior Notification This follows a previous review of mine that addressed the core helper function named make_skippable. The composition implementation presented ...
mahush's user avatar
  • 115
4 votes
1 answer
97 views

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

This is a follow-up question for A recursive_copy_if Template Function Implementation in C++ and recursive_invocable and recursive_project_invocable Concept Implementation in C++. I am trying to ...
JimmyHu's user avatar
  • 4,708
4 votes
1 answer
68 views

My C++ Implementation of the Observer Pattern

I have written my own basic implementation of the Observer pattern. Please code review it as you feel. This is a one file implementation, and any feedback no matter how small is appreciated. One ...
Archie Payne's user avatar
8 votes
2 answers
415 views

Image Rotation and Transpose Functions Implementation in C++

This is a follow-up question for Gaussian Fisheye Image Generator Implementation in C++ and An Updated Multi-dimensional Image Data Structure with Variadic Template Functions in C++. I am trying to ...
JimmyHu's user avatar
  • 4,708
3 votes
3 answers
1k views

Rock Paper Scissors Game feedback

I made this Rock Paper Scissors game using C++. This is my first time doing it and it took me around 3 hours. I know that since I am unexperienced, there is probably a much easier and shorter way of ...
Dalha Dalha's user avatar
2 votes
1 answer
35 views

Looking for feedback on a flavour of Radix tree I wrote. This is version 2 of the class original posted on this forum

My project explores some ideas i've had regarding alternate data structures to the unorderd_map and map, and aiming the exploration to key sets with a non uniform distribution and key sets with common ...
ver2's user avatar
  • 61
2 votes
1 answer
72 views

Scene Hierarchy with Translation, Rotation and Scale

This code represents an Entity Component that holds and manipulates an entity's local and world transforms, dealing with hierarchy and translation/rotation/scale transformations. The code is written ...
Daniel Marques's user avatar
4 votes
1 answer
72 views

Terminal based game: Part 3 (Using templated game)

Working from previous posts In this post: Terminal based game: Part 2 I introduced the concept of a Game object. To build a game like Terminal Base Snake you could ...
Martin York's user avatar
  • 95.1k
4 votes
1 answer
69 views

Terminal Base Snake

Based on this Framework Terminal based game: Part 2 A game that uses std::cout to print the board and std::cin to get keyboard ...
Martin York's user avatar
  • 95.1k
4 votes
1 answer
80 views

Terminal based game: Part 2

Follow up to: Terminal based game Finished up the framework. Still sticking with the X-Term based version. As I want a very simple framework to use for teaching (not this part initially). But my next ...
Martin York's user avatar
  • 95.1k
4 votes
2 answers
128 views

Game of life code in C++

Does my code for game of life look good enough? What changes can I make to optimize the code? I am a beginner to java and I've coded the Game of Life! For those not familiar, the game entails creating ...
ap0calypse's user avatar
6 votes
2 answers
2k views

Terminal based game

Looking to build a terminal based game. I am assuming X-Term like terminal. This means: I can use the X-Term control codes to clear and move around the screen. I can use ...
Martin York's user avatar
  • 95.1k
3 votes
1 answer
81 views

Gaussian Fisheye Image Generator Implementation in C++

This is a follow-up question for An Updated Multi-dimensional Image Data Structure with Variadic Template Functions in C++ and Three dimensional gaussian image generator in C++. I am trying to make a ...
JimmyHu's user avatar
  • 4,708
5 votes
2 answers
597 views

Generic multithreading solution for improving the performance of slow tasks

I'm currently in the process of replacing an archaic multithreading solution using some of the newer C++ standard library features now that our software has been updated to use C++20. Previously, most ...
Swepps's user avatar
  • 53
4 votes
1 answer
184 views

Looking for feedback on a flavour of Radix tree I wrote. The idea is speed on find() time if keys share common prefixes and are known ahead of time

My project explores some ideas i've had regarding alternate data structures to the unorderd_map and map, and aiming the exploration to key sets with a non uniform distribution and key sets with common ...
ver2's user avatar
  • 61
2 votes
2 answers
148 views

Is this a good pattern for handling late-initialized of class type?

Are there any issues with this class template? It is supposed to provide an easy-to-use object solution to initialize an object of class type after the declaration of the variable. One nuisance is the ...
Bolpat's user avatar
  • 233
1 vote
0 answers
45 views

An Updated recursive_transform_reduce Template Function with Unwrap Level Implementation in C++

This is a follow-up question for A recursive_transform_reduce Template Function with Unwrap Level Implementation in C++. To fix the issue mentioned in G. Sliepen's answer, I updated the test cases and ...
JimmyHu's user avatar
  • 4,708
2 votes
1 answer
44 views

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

This is a follow-up question for A recursive_transform_reduce Function for Various Type Arbitrary Nested Iterable Implementation in C++ and recursive_invocable and recursive_project_invocable Concept ...
JimmyHu's user avatar
  • 4,708
6 votes
1 answer
479 views

Checking to see if the current time is close to 9PM

I want to check if the current time is "close" to 9pm UTC. I have the following code to a.) get "now" and convert it to UTC time and b.) get 9pm utc time. Based off when I run it, ...
Taylor's user avatar
  • 241
4 votes
2 answers
97 views

TCP socket base class and Winsock implementation

I'm coding a chat application from scratch in modern C++. I'm currently building an interface for interacting with sockets. I want it to be cross platform. Am I approaching platform independence ...
Cherestes Radu's user avatar
5 votes
2 answers
535 views

Function templates for serializing/deserializing POD types

Are the two function templates below well-formed for serializing/deserializing POD types? Will they work for all the different types that satisfy the constraint pod?...
digito_evo's user avatar
3 votes
2 answers
99 views

Extending callable signature with std::optional in context of function composition (make_skippable)

(Please note: the post about the compose implementation announced below is now available.) This is about decorating callables by making their argument and return value to be a ...
mahush's user avatar
  • 115
3 votes
1 answer
112 views

C++ inline minimalist thread pool

This is a "minimal thread pool" I came up with to compare with a colleague's approach using Rust's Rayon's par_bridge() to automatically parallelize ...
Wasfi JAOUAD's user avatar
5 votes
1 answer
135 views

De/Serialize uint32_t from/to ASCII to use it in Arduino code

Despite the intention is to use it in a C++ project I put the c tag also because there is nothing C++-only (except references :)) in the code (I did not compile it ...
LRDPRDX's user avatar
  • 831
3 votes
1 answer
224 views

Logging in a different thread using circular buffer C++

What it does The code creates a logger class which instantiates a circular buffer at construction and uses producer-consumer style approach using condition_variable to log and print the messages to ...
wwite's user avatar
  • 33
3 votes
1 answer
107 views

Multithreaded natural language text parser (Rev.3)

This is the third iteration of the Multithreaded natural language text parser code review. Special thanks goes to G. Sliepen who conducted the first two reviews. Before reading this post, please read ...
Damir Tenishev's user avatar
2 votes
1 answer
54 views

recursive_find and recursive_find_if_not Template Functions Implementation in C++

This is a follow-up question for A recursive_find_if Template Function with Unwrap Level Implementation in C++ and recursive_invocable and recursive_project_invocable Concept Implementation in C++. I ...
JimmyHu's user avatar
  • 4,708
2 votes
1 answer
67 views

Multithreaded natural language text parser (Rev.2)

This is the second iteration of the Multithreaded natural language text parser code review. Special thanks goes to G. Sliepen who conducted the first review. Before reading this post, please read the ...
Damir Tenishev's user avatar
4 votes
1 answer
154 views

Trie implementation using std::shared_ptr

I've implemented a basic Trie that is supposed to work only with lowercase English letters. ...
csmathhc's user avatar
  • 153
1 vote
2 answers
78 views

Advent of Code 2023 day 1: Trebuchet (Part 2)

Task: The task involves analyzing a calibration document containing lines of text. Each line represents a calibration value that needs to be recovered by extracting the first and last digits (which ...
Harith's user avatar
  • 5,834

1
2 3 4 5
190