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
5 votes
2 answers
458 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
0 votes
0 answers
12 views

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

This is about decorating callables by making their argument and return value to be a std::optional. Therefore I created the template function ...
mahush's user avatar
  • 1
3 votes
1 answer
82 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
120 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
194 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
70 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
45 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,382
-4 votes
0 answers
32 views

(c++) std::system_error (Operation not permitted) when trying to lock inside a shared_ptr/unique_ptr [closed]

Here is the situation: ...
Oberon's user avatar
  • 1
2 votes
1 answer
55 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
139 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
63 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
  • 4,093
2 votes
1 answer
41 views

recursive_invocable and recursive_project_invocable Concept Implementation in C++

This is a follow-up question for A recursive_find_if Template Function with Unwrap Level Implementation in C++. I am trying to make some constrains on Proj and <...
JimmyHu's user avatar
  • 4,382
2 votes
1 answer
91 views

Multithreaded natural language text parser

Could you please conduct code review for the code below and suggest some improvements? Functional specification Implement a multithreading parser based on existing natural language tokenizer. Parser ...
Damir Tenishev's user avatar
4 votes
1 answer
142 views

Natural language text fast tokenizer (Rev.5)

This is the next iteration of the Natural language text fast tokenizer code review. Special thanks goes to G. Sliepen, Toby Speight and uli who conducted previous reviews and to Matthieu M. and Adrian ...
Damir Tenishev's user avatar
4 votes
3 answers
1k views

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

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 and ...
Harith's user avatar
  • 4,093
3 votes
1 answer
91 views

Performing tasks on for-loop over thousands of items in Rcpp

I am trying to adapt an R script that I wrote to perform several tasks in a for-loop. The for-loop run over thousands of items, for about 900 times, therefore I would like to optimise my code at the ...
CafféSospeso's user avatar
3 votes
1 answer
66 views

Natural language text fast tokenizer (Rev.4)

This is the forth iteration of the Natural language text fast tokenizer code review. Special thanks goes to G. Sliepen, Toby Speight and uli who conducted previous reviews and to Matthieu M. and ...
Damir Tenishev's user avatar
-1 votes
0 answers
40 views

How can my first chess game be improved, tested and AI integrated

EDIT: I shouldve clarified this in my first post but the code absolutley works however the X and Y coords are switched e.g 0,0 = top left, 1,0 = 2nd row, 3,0 = 3rd row etc This is the final version of ...
Liam V's user avatar
  • 119
5 votes
2 answers
506 views

Natural language text fast tokenizer (Rev.3)

This is the third iteration of the Natural language text fast tokenizer code review. Special thanks goes to G. Sliepen, Toby Speight and uli who conducted previous reviews and to Matthieu M. and ...
Damir Tenishev's user avatar
6 votes
2 answers
323 views

A simple find function with concepts

I have written the following simple find function template that does a linear search. ...
digito_evo's user avatar
3 votes
3 answers
1k views

First C++ Program: Race Car Driver Points Calculator

Task: Write a program that is given three numbers corresponding to the number of times a race car driver has finished first, second, and third. The program computes and displays how many points that ...
Harith's user avatar
  • 4,093
3 votes
1 answer
100 views

Natural language text fast tokenizer (Rev.2)

This is the second iteration of the Natural language text fast tokenizer code review. Special thanks goes to G. Sliepen and Toby Speight who conducted the first review. Functional specification ...
Damir Tenishev's user avatar
4 votes
1 answer
148 views

Track and trace allocations

When testing or debugging allocator-aware objects, it can be useful to provide allocators that can provide insight into how they get called. The Tracing_alloc from ...
Toby Speight's user avatar
  • 74.5k
6 votes
2 answers
494 views

Natural language text fast tokenizer

Could you please conduct code review for the code below and suggest some improvements? Functional specification Implement a function for fast tokenization of text in char[] buffer handling some ...
Damir Tenishev's user avatar
1 vote
2 answers
59 views

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

This is a follow-up question for A recursive_find_if_all Template Function Implementation in C++, A recursive_all_of Template Function Implementation in C++ and A recursive_all_of Template Function ...
JimmyHu's user avatar
  • 4,382
2 votes
1 answer
38 views

A collection based on a bitset to store a set of unique integers from a given range (rev. 3)

All right, let's do this one last time. This is continuation of this review. I applied most of the proposed changes, making interface of my container very close to that of ...
Piotr Siupa's user avatar
6 votes
1 answer
923 views

Split command in C++20

The Windows OS doesn't feature a Split command and although I do have a Linux partition, I mainly use Windows 11. As such, I implemented the ...
machine_1's user avatar
  • 581
5 votes
2 answers
399 views

Demonstrate effects of summation order

When we add lots of floating-point values, we can lose precision if we blindly use std::accumulate() or similar, when the running total becomes much larger than the ...
Toby Speight's user avatar
  • 74.5k
4 votes
2 answers
295 views

Count the frequencies of each word in a file

I have tried to implement a code that does the following: store words in an array (unordered) use function order_array() to place repetitions for the same word ...
Arsenio's user avatar
  • 43
3 votes
1 answer
77 views

Writing a multidimensional array view for contiguous arrays in C++20

When creating little games or other programs I often need multidimensional arrays. Usually I just do the simple std::vector<std::vector<T>> thing for ...
Joel's user avatar
  • 133
5 votes
3 answers
1k views

A Dynamic Bitset that I wrote and will use in my compression algortithm. This will be used to store the chars as bits from fstream

I have currently implemented an increment method. A method to add bytes. And a method to print out the bitset.   Main.cpp ...
Christian Phillips's user avatar
4 votes
1 answer
70 views

A collection based on a bitset to store a set of unique integers from a given range (rev. 2)

This is a continuation of this review. I applied most of the proposed changes. These changes were focused mostly on decoupling the class from the rest of the program and making its interface more like ...
Piotr Siupa's user avatar
3 votes
1 answer
65 views

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

This is the forth iteration of the Fast search for the longest repeating substrings in large text (Rev.3) code review. Special thanks goes to G. Sliepen who conducted all the reviews. Functional ...
Damir Tenishev's user avatar
3 votes
1 answer
42 views

Graphical Visualizer in terminal V[2]: using it visualizing: falling sand sim, sorting algorithms and the game of life

this is the second version of this project, you can check previous post here: Terminal Graphical Visualizer, using a queue of different matrices I implemented bare-bones version of ncurses library (...
Ellie's user avatar
  • 497
3 votes
2 answers
158 views

Rock, paper, and scissors C++

Could you give me your opinion about this simple rock, paper, and scissors game code and tell me tips to improve this code? ...
salah salah's user avatar
3 votes
1 answer
188 views

Generic feedback on a replacement of `<cctype>`

I use a lot <cctype> functions, but they're not very type safe and and calling them with a negative char is (theoretically) undefined behavior, so my code is ...
MatG's user avatar
  • 149
2 votes
1 answer
74 views

Multi Threaded File Processing C++

Background: The program reads 1000000 lines in the file. Every four line will be parsed into an object in a vector. If it has 2 objects with the same name, it will drop 1 object and increment one of ...
SummerGram's user avatar
2 votes
1 answer
54 views

Using std::variant

Have been using std::variant for the first time. Accidentally stumbled on a pattern that seems resonable but wanted to get a second opinion. I have a class that can ...
Martin York's user avatar
  • 94.6k
3 votes
1 answer
37 views

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

This is a follow-up question for A recursive_find_if_all Template Function Implementation in C++ and A recursive_all_of Template Function Implementation in C++. To support ...
JimmyHu's user avatar
  • 4,382
3 votes
1 answer
84 views

C++ OpenGL Game Engine

I am currently developing a C++ OpenGL game engine to help myself learn computer graphics and game design later on. However, this project is becoming really big, and I am unsure if I am making the ...
kiru's user avatar
  • 31
26 votes
5 answers
8k views

Rock Paper Scissors. My first C++ program. Please judge harshly

I am new and only know the basics of C++. Any help will be appreciated. I want to know how to make my code less lines, more efficient, proper practice and play better. ...
Sammyng's user avatar
  • 369
4 votes
1 answer
178 views

Fill vector of unique_ptr<derived> only with required derived types and enforce multiplicities constraints

I wrote a function that accepts a destination vector and a vector of all the types that are currently available. Its job is to iterate over all the available types (strings) and for each type, if it's ...
lia's user avatar
  • 43
1 vote
0 answers
54 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
199 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
120 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
93 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
85 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
110 views

Implement document processing system

I have to implement a class with method that takes document: ...
mascai's user avatar
  • 369
2 votes
1 answer
175 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

1
2 3 4 5
190