Questions tagged [c++20]
Code that is written to the 2020 version of the C++ standard. Use in conjunction with the 'c++' tag.
339 questions
4
votes
2
answers
414
views
Get histogram of bytes in any set of files in C++20
Intro
This post is the continuation of Get histogram of bytes in any set of files in C++14 - take II. This time, I have incorporated almost all suggestions in the answers.
Code
My newest trial looks ...
4
votes
3
answers
368
views
PIMPL based logging interface to print multiple parameters at once
I have implemented my own logger based pimpl idiom. As a third party lib, I used spd log. My focus is to provide an interface to the end user who wants to print multiple parameters at once. I also ...
2
votes
1
answer
95
views
Framework for object creation and method invocation using strings (for use with scripting)
My team is working on replacing our in-house scripting solution which will allow users to control the software and access data using their own external scripts.
The plan is to use a class hierarchy ...
4
votes
2
answers
442
views
Second Try at C++ 20 Generic Dictionary for enums and Strings
This is a follow up question to Abstract Generic Dictionary. Some of the code reviewed in this question was also reviewed in C++20 Performance Test Code Generator.
The new template class attempts to ...
3
votes
1
answer
67
views
Simple Web Server
Getting close to the library I want.
Here is me using the library I have been posting in chunks to build a functional Web Server. Any suggestions on code or interface changes. I want the code to look ...
5
votes
1
answer
261
views
Converting a char string to wchar_t string based on a given toWideStr() starting point
I'm working on a legacy code base and I came across a method in which I wanted to remove the chance of swallowing an exception. In the following I want to walk you through the refacoring process, ...
6
votes
2
answers
43
views
STL style iterator template for arbitrary trees in C++20
In different code bases I regularly encounter tree data structures of different design and usually need to traverse it at some point. I finally got tired of writing yet another iterative traversal by ...
2
votes
1
answer
65
views
C++ CoRoutine Second Try building a range
Second try.
This time rather than get() and operator bool make the handle be a range operator.
The only difference in the ...
0
votes
0
answers
28
views
C++ CoRoutine First Try
Lazy range generator.
I know everybody's first example for co-routines.
But want to get some feedback.
The code
...
2
votes
2
answers
127
views
C++20 Performance Test Code Generator
My previous question about a generic dictionary class for C++ raised some valid concerns. I have made some modifications based on the previous review, but it needs extensive testing and further ...
8
votes
4
answers
1k
views
Generic C++ Class to Associate enum Values with Strings for Translation
This is the first time I am using C++ templates in a very long time, and is the first time I have created a template class.
When developing projects I often run into a common problem: I have an enum ...
1
vote
1
answer
88
views
set Member Function Implementation for Image in C++
This is a follow-up question for draw_if_possible Template Function Implementation for Image in C++. In G. Sliepen's answer, set member function has been mentioned. ...
5
votes
1
answer
109
views
Replacement for 'enum class' with string functionality
Because I think maintainability can be done better with strings instead of plain enumerator-values when doing fstream IO, I wanted a replacement struct in my project that behaves like an ...
1
vote
1
answer
157
views
A unique_ptr-like class, for spans instead of raw pointers
Introduction / Motivation
I like the CADRe (a.k.a. RAII) resource management idiom in C++. And I like std::span's; or perhaps I should say, I dislike the use of ...
1
vote
0
answers
65
views
difference_of_gaussian Template Function Implementation for Image in C++
This is a follow-up question for conv2 Template Function Implementation for Image in C++ and imgaussfilt Template Function Implementation for Image in C++. I am trying to perform Difference of ...
3
votes
1
answer
281
views
imgaussfilt Template Function Implementation for Image in C++
This is a follow-up question for im2double and im2uint8 Functions Implementation for Image in C++, conv2 Template Function Implementation for Image in C++ and An Updated Multi-dimensional Image Data ...
2
votes
0
answers
32
views
A recursive_replace_copy_if Template Function with Unwrap Level Implementation in C++
This is a follow-up question for A recursive_replace_copy_if Template Function Implementation in C++. I am trying to implement recursive_replace_copy_if template ...
3
votes
2
answers
285
views
im2double and im2uint8 Functions Implementation for Image in C++
This is a follow-up question for conv2 Template Function Implementation for Image in C++ and An Updated Multi-dimensional Image Data Structure with Variadic Template Functions in C++. For performing ...
2
votes
0
answers
42
views
Convert Image Class to OpenCV Mat Data Structure in C++
This is a follow-up question for An Updated Multi-dimensional Image Data Structure with Variadic Template Functions in C++. I am trying to build the bridge to perform the conversion between the ...
8
votes
3
answers
2k
views
is_decimal Function Implementation in C++
This is a follow-up question for is_number Function Implementation in C++. Considering G. Sliepen's answer and Harith's answer, I want to focus on decimal number here, therefore, ...
2
votes
1
answer
71
views
Calculating array segment uniformity using a segment tree
You have to analyze some array of \$n\$ numbers. In particular, you are interested in the so-called array uniformity. Suppose that in the array the number \$b_1\$ appears \$k_1\$ times, \$b_2\$ \$k_2\$...
2
votes
2
answers
96
views
Minimum length of specific substrings
Given the string \$s\$. It is required to answer n queries. The \$i\$th query consists of an integer \$k_i\$ and a string \$m_i\$, the answer is the minimum length of the string \$t\$ such that \$t\$ ...
6
votes
3
answers
200
views
Find the number of cycles of length 3
Given the count. Find the number of cycles of length 3.
Input format: The first line contains two integers n and m (1 < n, m ≤ 3✕10⁵) — the number of vertices and edges, respectively. Each of the ...
6
votes
1
answer
482
views
Generate unique temporary file names in C++20
WARNING: do not use this solution
See discussion in the accepted answer's comments. Basically, this solution would reproduce std::tmpnam's and ...
6
votes
1
answer
388
views
C++ program to format byte sequences into Python like string representations
This is a C++ program I wrote, that includes functions to convert integers to byte sequences in little endian or big endian order, and functions to convert a byte sequence to a string representation.
...
6
votes
3
answers
508
views
locale-aware trim functions for std::string
I have written the below two trim functions for std::string and std::basic_string that are locale-aware.
Both trim all white ...
8
votes
3
answers
2k
views
fmap for containers in c++
I implemented a simple fmap for containers. However containers don't have a unified function to add elements. So I wrote different concepts for different containers. Is there a better way to implement ...
3
votes
1
answer
166
views
Advanced String Calculator in C++
This is a follow-up question for String Calculator in C++. Considering the suggestions mentioned in MrBean Bremen's answer and Martin York's answer. I am trying to modify the code and trying to ...
4
votes
2
answers
168
views
String Calculator in C++
As a coding exercise, I am trying to implement a calculator which takes string as input, with addition (+), subtraction (-), multiplication (*), division (/) and power (^) functions. For example, ...
4
votes
2
answers
691
views
is_number Function Implementation in C++
I am trying to implement a function which can determine a string is a number or not. Both positive and negative integers / floating numbers are considered.
The experimental implementation
...
4
votes
0
answers
99
views
Image Rotation with Shear Transformation in C++
This is a follow-up question for Image Rotation and Transpose Functions Implementation in C++ and An Updated Multi-dimensional Image Data Structure with Variadic Template Functions in C++. I am trying ...
1
vote
0
answers
41
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 ...
1
vote
1
answer
38
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 ...
4
votes
1
answer
102
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 ...
8
votes
2
answers
469
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 ...
2
votes
1
answer
62
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 ...
3
votes
1
answer
97
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 ...
6
votes
2
answers
622
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 ...
4
votes
1
answer
192
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 ...
1
vote
0
answers
53
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 ...
2
votes
1
answer
63
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 ...
3
votes
1
answer
247
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 ...
2
votes
1
answer
57
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 <...
1
vote
2
answers
72
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 ...
2
votes
1
answer
52
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 ...
6
votes
1
answer
953
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 ...
3
votes
1
answer
128
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 ...
4
votes
1
answer
86
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 ...
3
votes
1
answer
197
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 ...
3
votes
1
answer
43
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 ...