Skip to main content

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

Stand/Bench for testing emergency situations for 2p2 networks in games

In fact, this is a throttling proxy. It can work in two modes: "paired" and "multi-Client". In "pair" mode, two clients connect to each other through a proxy, very ...
Alexovsky's user avatar
2 votes
3 answers
218 views

Fast tolower function

C++ Standard Library functions like std::tolower, std::isalpha, etc. could be quite slow when it comes to large texts and handling locales. So, I decided to have fast tolower function, caching the ...
Damir Tenishev's user avatar
3 votes
1 answer
129 views

Incremental upper bound in sorted range

Since initial question Increasing binary search for mismatch in sorted range contained defects in code and can confuse the readers, here is the updated version of the question. Is the code below ...
Damir Tenishev's user avatar
2 votes
1 answer
114 views

Fast search for the longest repeating substrings in large text (Rev.3)

This is the third iteration of the Fast search for the longest repeating substrings in large text (Rev.2) code review. Special thanks goes to G. Sliepen who conducted the first two reviews. Functional ...
Damir Tenishev's user avatar
2 votes
3 answers
111 views

A dynamic array with an iterator compatible with std::sort

I wrote a Vector (dynamic array) class with an iterator usable with std::sort() . It seems to pass my tests. I wondering about the issues one can spot on this ...
KcFnMi's user avatar
  • 119
1 vote
2 answers
119 views

Implement document processing system

I have to implement a class with method that takes document: ...
mascai's user avatar
  • 379
2 votes
1 answer
183 views

Code for functionality like "valid pointer or default" and "true or default"

Relatively new to C++, not sure if I'm doing everything right, any advice would be appreciated. The site does not allow me to post this question with that little actual text, so I am artificially ...
Юрыч BRO's user avatar
1 vote
1 answer
79 views

Collection that uses a bitset to store a huge set of unique integers from a given range (rev. 1)

Some (skippable) context: I'm writing program that minimizes an arbitrary logical function. Such function takes an unsigned integer as an argument and returns either ...
Piotr Siupa's user avatar
2 votes
1 answer
77 views

string compatible enum-like structure

So I've decided to flex showcase my "enum that accepts strings etc..." here. I don't know if it's great but I'm pretty sure it's decent. It is implemented in less than 200 lines of code (not ...
PinkTurtle's user avatar
1 vote
1 answer
59 views

A recursive_find_if_all Template Function Implementation in C++

This is a follow-up question for recursive_any_of and recursive_none_of Template Functions Implementation in C++. I am trying to follow the suggestion of G. Sliepen's answer to implement ...
JimmyHu's user avatar
  • 5,360
2 votes
2 answers
133 views

Robot arm control

The code in question is in GitHub here. arm.h, armconstants.h and arm.cpp. Here are the key passages: arm.h ...
pitosalas's user avatar
  • 153
2 votes
1 answer
96 views

Fast search for the longest repeating substrings in large text (Rev.2)

This is the second iteration of the Fast search for the longest repeating substrings in large text code review. Special thanks goes to G. Sliepen who conducted the first review. Functional ...
Damir Tenishev's user avatar
4 votes
1 answer
66 views

Terminal Graphical Visualizer, using a queue of different matrices

I built a project in which I provide a string input or a whole matrix to configure a frame, create a bunch of different frames and push them into a queue and finally print them in order of the queue. ...
Ellie's user avatar
  • 549
5 votes
1 answer
121 views

Locate and multiply numbers in a 2D grid (Advent of Code 2023 Day 3, Part 2)

I am using the Advent of Code 2023 to study functional programming and the ranges library in C++. This code is for the second part of Day 3 and is the best solution using FB I've created. I'd ...
rm1948's user avatar
  • 185
1 vote
1 answer
45 views

recursive_any_of and recursive_none_of Template Functions Implementation in C++

This is a follow-up question for A recursive_all_of Template Function Implementation in C++ and A recursive_count_if Function For Various Type Arbitrary Nested Iterable Implementation in C++. Besides <...
JimmyHu's user avatar
  • 5,360
2 votes
1 answer
342 views

Chain of Responsibility pattern for dealing with multiple changes

In Dungeons and Dragons, when one puts on multiple magical items, all of its effects will take place. These effects are to be cumulative, so if Girdle of Strength adds 2 to one's strength, and a ...
prestokeys's user avatar
  • 1,371
2 votes
2 answers
83 views

A recursive_all_of Template Function Implementation in C++

This is a follow-up question for A recursive_foreach_all Template Function Implementation in C++. I am trying to implement recursive_all_of template function in ...
JimmyHu's user avatar
  • 5,360
12 votes
3 answers
1k views

Chess game: board and moves

I'd like to preface this by saying firstly, my code is absolutely nowhere near complete, and secondly that I am essentially brand new to coding and this is my first real project. I like to be thrown ...
Liam V's user avatar
  • 121
3 votes
2 answers
67 views

Palindrome predicate

A standard beginner problem is to determine whether a particular input is palindromic, i.e. reads the same in reverse as it does forwards. I thought it might be fun to provide a distinctly non-...
Toby Speight's user avatar
  • 77.3k
3 votes
1 answer
180 views

Fast search for the longest repeating substrings in large text

Is there a chance to implement the code below better with the features of recent C++ versions? Functional specification Having a large text and already built prefix array find the longest substrings (...
Damir Tenishev's user avatar
4 votes
2 answers
335 views

C++ Deque Implementation

Took a shot at implementing std::deque in C++. I aimed for amortized O(1) push_front and <...
jdav22's user avatar
  • 361
8 votes
1 answer
727 views

library for converting numbers to HEX

This is library for fast converting "HEX strings" to unsigned numbers and vice versa. The result is not defined, if input is incorrect, e.g. string "ZZZ1" will be converted to ...
Nick's user avatar
  • 1,582
2 votes
3 answers
173 views

Wrap a noexcept C++ library method with a method throwing exceptions with usable explanatory strings to stay DRY

In our apps we're using a shared inhouse library which provides filesystem functions. All the functions are noexcept. In several apps i found that similar or identical error return translations are ...
ridilculous's user avatar
3 votes
1 answer
212 views

Calculate the maximum number of decimal places with which all floating point numbers can be represented in a range in C++

I'm looking for a function in C++ that can determine, how accurate all floating point numbers in a given range can be represented as strings, without the use of e.g. boost library, etc. Please take a ...
Tobias Grothe's user avatar
3 votes
2 answers
143 views

Beginner Rock-Paper-Scissors game

As a beginner, this is my second game in C++. It is a very simple rock-paper-scissors game. User or computer wins the game after a given number of rock,paper or scissors matches. I'd appreciate any ...
Gizem's user avatar
  • 105
7 votes
3 answers
809 views

Number Guessing Game in C++

I am very new to C++ and I've tried to write a simple number guessing game. I know it is a basic task but I'd really appreciate any feedback that could help me improve my writing. Thanks! ...
Gizem's user avatar
  • 105
4 votes
2 answers
442 views

Z-Function/ Algorithms on strings. C++

The problem: Given a string s. For each i from 1 to |s|, find the number of occurrences of its prefix of length i in the string. Input: The first line of input contains an integer q (1≤q≤10⁵) — the ...
neely's user avatar
  • 43
2 votes
1 answer
58 views

Reading a date from the start of a text webpage from github to determine if the program is fully updated

...
my_stack_exchange_account's user avatar
2 votes
1 answer
144 views

Acceleration of Hidden Markov Modell likelihood calculation in Rcpp

I wrote the following code in Rcpp, i.e. it is C++ code that is compiled in R for making faster calculations. The code in Rcpp is intended to calculate in a recursive way the likelihood function for ...
Jonathan1234's user avatar
4 votes
3 answers
481 views

Templated linked list

I have created a templated linked list to take different objects. I was told to put this up for code review as it could use some improvements. To be honest, I am not completely sure when to use the '...
Peazypound1212's user avatar
3 votes
1 answer
102 views

(C++) Template code for adding tagging types to add additional context

Below is a piece of template code which allows for adding a Tag to structure or class types. ...
Sam Coutteau's user avatar
1 vote
1 answer
118 views

Fraudulent activity notifications problem from hackerrank

There's a problem on hackerrank called fraudulent activity notifications: given an array of integers and a value k, I'm supposed to increment a counter if the median of the numbers up until k , ...
IRP_HANDLER's user avatar
4 votes
1 answer
100 views

Parametric - a simple program argument parser

I've made a little header-only library for handling user input for console applications, I'd really appreciate it if you guys took a short look at it and told me what you think. The goal of the ...
Goubermouche's user avatar
1 vote
1 answer
136 views

Quadratic equation solution solution searcher

Here is a simple Learner practice piece of Code, which supposses to comply and give solutions to a Quadrant Equity problem (requires to give it values of a, b and c for a Quadrant function). Please ...
Pale Broccoli's user avatar
1 vote
0 answers
52 views

C# like Dependency injection for C++ on embedded device

I was wondering if it would be possible to create a C# like syntax for dependency injection. My device is running constantly and acting more or less like a service. I came up with the following. My ...
Bas Visscher's user avatar
1 vote
1 answer
94 views

An Updated Multi-dimensional Image Data Structure with Variadic Template Functions in C++

This is a follow-up question for Multi-dimensional Image Data Structure with Variadic Template Functions in C++. Considering the suggestion from G. Sliepen: Make everything work for more than 5 ...
JimmyHu's user avatar
  • 5,360
2 votes
0 answers
38 views

Barebones Qt/QML app that generates a list of dishes and then a shopping list with ingredients

I have written a simple app that generates a menu in the form of a list of recipes. It furthermore generates a shopping list, given a menu, consisting of the (unique) ingredients in the recipes that ...
Michele Bolognini's user avatar
5 votes
1 answer
282 views

Space efficient arrays

I needed a very space-efficient structure to store an array for which elements are unsigned integers with an upper bound known at runtime. I'm not an expert in pointer arithmetic, so I'm not sure if ...
fontanf's user avatar
  • 151
4 votes
2 answers
164 views

Header only logging library in C++

Source Code I've attempted to create a simple logging library in cpp. My goal was to make it lightweight to incorporate and easy to add to the codebase. ...
Saphereye's user avatar
  • 233
5 votes
1 answer
93 views

Checkup for a block of memory, containing a repeated single byte

I was looking at this question on SO, because I needed something similar. There are eight answers to it, and I wasn't satisfied with any of them - so I've written my own solution (please see below). ...
HEKTO's user avatar
  • 217
3 votes
1 answer
98 views

Is it valid to pass struct through std::fold_left to persist state?

I am exploring functional programming design with C++. The code below uses a struct passed to ranges::fold_left for processing. The final result is returned in the ...
rm1948's user avatar
  • 185
5 votes
1 answer
283 views

Multi-dimensional Image Data Structure with Variadic Template Functions in C++

This is a follow-up question for Three dimensional data structure in C++. I am trying to implement multi-dimensional image data structure with variadic template functions. For example, ...
JimmyHu's user avatar
  • 5,360
3 votes
1 answer
124 views

Dynamic code syntax error reporting

Full code is below. Any feedback is welcomed. I am trying to implement syntax error reporting like GCC and other ...
Alix Blaine's user avatar
3 votes
1 answer
102 views

A Windows localhost key logger in C++ with WinAPI

Now I have this repository. It's a key logger logging all the keyboard events possible. Note that some programs do not "leak" the keyboard events outside of their GUI. For example, Notepad++ ...
coderodde's user avatar
  • 28.9k
5 votes
2 answers
830 views

Three dimensional data structure in C++

This is a follow-up question for Three dimensional gaussian image generator in C++. Considering the suggestion from G. Sliepen: Structure of a 3D image Your 2D ...
JimmyHu's user avatar
  • 5,360
2 votes
1 answer
160 views

ESP32-12: Sample analog audio and send it via udp

I want to sample audio as a learning process. In the future i want to make my dorbell "smart" and stream the audio via VoIP. But as beginning i want to sample a simple audio signal from my ...
Marc's user avatar
  • 153
3 votes
2 answers
110 views

Learn.cpp chapter 8 exercise add error handling to the high low game

I did the exercise of LearnCpp.com's Chapter 8 summary and quiz and I'm still learning… Question #3 Implement a game of hi-lo. First, your program should pick a random integer between 1 and 100. The ...
Maria David's user avatar
2 votes
1 answer
839 views

Efficient parallelization of small tasks

Problem statement: Consider a scenario where a vector of very small tasks, each encapsulated within a class 'Task' with a thread-safe method Task::process(), needs to be efficiently processed in ...
Shakti Malik's user avatar
4 votes
3 answers
2k views

A very simple config file parser in C++

I've implemented a config file parser in C++, which I may expand in future for personal projects. As of now the config file only supports floats, strings and booleans. The parser is based on various <...
Agent_A's user avatar
  • 73
1 vote
1 answer
90 views

Conway's Game of Life In C++17

I implemented Conway's Game of Life in C++17. To make it easy to copy paste. I have merged my .h and ...
Ajinkya Kamat's user avatar