Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Questions tagged [c++20]

Code that is written to the 2020 version of the C++ standard. Use in conjunction with the 'c++' tag.

Filter by
Sorted by
Tagged with
1 vote
0 answers
9 views

C++ Hash table, Hash function, benchmark vs std::unordered_set and std::hash

I wrote my own hash function and my own hash table. My hash function seems to work surprisingly well! Feel free to comment anything! Hash function: ...
user avatar
  • 1,181
2 votes
1 answer
37 views

C++ Doubly linked list, including benchmark vs std::list

I wrote a rudimentary implementation of doubly linked list. Feel free to comment anything! ...
user avatar
  • 1,181
2 votes
1 answer
56 views

C++20 Multi-queue Thread Pool with Work Stealing

This is a follow up to my previous post which also follows up on my first post regarding my thread pool implementation. I have since made some further changes and attempted to improve performance with ...
user avatar
1 vote
1 answer
60 views

Using std::variant with std::ranges algorithms

I have some predicate objects that take some value and return the result of some criteria. (My real implementation is more complex, this is only a minimal example): Run on Compiler Explorer ...
user avatar
  • 125
1 vote
1 answer
94 views

Storing different types with common base using atomic-based typeid

I'm trying to develop some kind of in-memory store for my entities. These entities are representations of the devices available on the system. There may be eg. 3 leds, 1 temp sensor, 2 engines etc. ...
user avatar
  • 241
2 votes
1 answer
41 views

UPDATE #1: Lengthening the time it takes to access files using function hooking

https://github.com/speedrun-program/load_extender This is the previous post: Lengthening the time it takes to access files using function hooking I tried adding everything from the previous post's ...
user avatar
2 votes
1 answer
53 views

Lengthening the time it takes to access files using function hooking

https://github.com/speedrun-program/load_extender This is something I made and posted here about a year ago, but I decided to remake it. To compile this on Windows, you need to install EasyHook. ...
user avatar
0 votes
1 answer
21 views

C++20 Wrapper class for an unsigned integer type and a templated derived class that codes modular arithmetic type

The context is a library to represent numbers (in this case integers) by wheighted position by radix powers for every radix R, passed as template argument. These derived types are digits of radix R, ...
user avatar
1 vote
1 answer
45 views

Verified downcasting if RTTI is active

In an application that uses heavily polymorphic classes, I have often the need to downcast a pointer or a reference to the correct derived class. They should always be of the correct derived class, ...
user avatar
  • 188
1 vote
1 answer
90 views

C++ merge sort, logging, unit test, performance check

I wrote a merge sort implementation in C++ today in C++20 way. ...
user avatar
  • 1,181
21 votes
6 answers
8k views

I created something much faster than a std::string

I've recreated std::string in a way that might be faster. System Features: Much faster than std::string. Easy to use. It was designed as part of a large database ...
user avatar
  • 351
1 vote
1 answer
68 views

Yet another command / event dispatcher

I'm trying to implement some kind of command dispatcher. I've already developed some code, but I'm not sure about a few things. My dispatcher is a simple command dispatcher, so for each command, there ...
user avatar
  • 241
3 votes
1 answer
121 views

Mapping between Enum <-> Enum <-> String view

I've been working on some kind of mapper that would allow me to map between types. My objectives: it should allow mapping between two enums it should allow mapping enum to string_view it should allow ...
user avatar
  • 241
4 votes
2 answers
141 views

C++20 Single Queue Thread Pool

This is a follow up to my previous post. I've made a number of improvements to the thread pool and corrected some bugs as well. The most up to date version of the code is available on my Github. I ...
user avatar
4 votes
1 answer
120 views

Searching for a performance bug in a C++20 pathfinding algorithm (NBA*)

(See the next iteration.) I have this pathfinding algorithm: DirectedGraph.hpp ...
user avatar
  • 25.3k
3 votes
1 answer
45 views

checked conversion function for C++20

Similar to C++ int_cast<> function for checked casts?, but C++20, and with target type deduced from context. The goal is to implement a runtime check that the value being converted can be ...
user avatar
3 votes
1 answer
71 views

function template for string_view-to-integer conversion

I want to make the following function a function template that supports all the integral types: ...
user avatar
1 vote
1 answer
31 views

functor chaining function for c++20

How might chain_apply() be improved? ...
user avatar
  • 1,354
5 votes
3 answers
405 views

generic implementation of median

Below is a generic implementation of the summary statistics function Median. Discussion of efficient use of std::nth_element and ...
user avatar
0 votes
1 answer
44 views

Class accepting data input by variable, function pointer or lambda

Background I am writing a library that takes some data from the user and works with it. I was experimenting with ways to allow users to provide the data by the following methods: As a (global) ...
user avatar
  • 103
1 vote
1 answer
79 views

Strong typing -> Named type

I'm trying to generate a strong(er) type wrapper for C++. I've seen the NamedType by Jonathan Boccara, but I want a slightly different behavior. Ideally I would be ...
user avatar
6 votes
3 answers
655 views

Custom string-to-int converter

I have written the following function: ...
user avatar
14 votes
2 answers
1k views

Block-free priority lock

Background I wanted to write an event loop that supports scheduling, but found that no implementation of priority queue that I know of supports waiting on a condition variable (the idea is that the ...
user avatar
  • 9,049
2 votes
1 answer
75 views

An rough implementation of `std::is_constructible`

As a challenge/fun activity/task, I have implemented my version of std::is_constructible. Here is the source code: ...
user avatar
5 votes
4 answers
2k views

C++ basic bank money class

I am trying to create a basic money class that fits into a small console banking application I am making. Money.h ...
user avatar
2 votes
2 answers
79 views

Checking image size in C++

This is a follow-up question for 3D Inverse Discrete Cosine Transformation Implementation in C++. After checking G. Sliepen's answer, I am trying to update the part of width and height checking of <...
user avatar
  • 3,302
6 votes
4 answers
295 views

Nelder-Mead optimization in C++

I've implemented the Nelder-Mead optimization algorithm in C++. I found this document to be a very good explanation of how the algorithm works, but I'll try my best to explain it (with an example) ...
user avatar
  • 12.2k
2 votes
0 answers
57 views

invocable_traits v5

Goal: implement traits that for anything callable return its arity, return type and the argument types. Since pointers to data members are also callable, those should be handled (and be considered 0-...
user avatar
1 vote
1 answer
60 views

invocable_traits v4

Update: there is a new version of this code: v5 is posted here Goal: implement traits that for anything callable return its arity, return type and the argument types. Since pointers to data members ...
user avatar
3 votes
0 answers
42 views

invocable_traits v3

Update: there is a new version of this code: v4 is posted here Goal: implement traits that for anything callable return its arity, return type and the argument types. Since pointers to data members ...
user avatar
1 vote
1 answer
41 views

c++ multithreaded message broadcaster with link lifetime management v2

note: This is v2 of code that was previously reviewed. I have written a class that handles listeners registering callbacks to receive messages. Link lifetime is managed (or is it?). Code is ...
user avatar
1 vote
1 answer
35 views

c++ multithreaded message broadcaster with link lifetime management

note: A version of this code without link lifetime management was previously reviewed. Adding lifetime management actually made the code simpler, and the class simpler to use. I have written a class ...
user avatar
3 votes
1 answer
46 views

invocable_traits

Update: there are new versions of this code: v3 is posted here and v4 is posted here Goal: implement traits that for anything callable return its arity, return type and the argument types. Since ...
user avatar
2 votes
1 answer
69 views

callable_traits implementation

Update: there are new versions of this code: v2 is posted here, v3 is posted here and v4 is posted here Goal: implement traits that for anything callable return its arity, return type and the ...
user avatar
0 votes
1 answer
49 views

Advent of Code 2021 Day 4: Play Bingo against a Giant Squid

[This is my first post here - though I have been lurking in the back reading, plussing, and hopefully learning for over two years] Below is my solution for Advent of Code 2021 Day 4, where you are ...
user avatar
  • 188
9 votes
1 answer
445 views

3D Inverse Discrete Cosine Transformation Implementation in C++

This is a follow-up question for 3D Discrete Cosine Transformation Implementation in C++. In this post, I am trying to follow user17732522's answer to update ...
user avatar
  • 3,302
2 votes
1 answer
137 views

c++20 compile time string utility v2

This is a follow up on c++20 compile time string utility, as suggested by G. Sliepen posted as a new question, so it can be reviewed on its own. The following code has suggested improvements from the ...
user avatar
  • 65
6 votes
1 answer
211 views

3D Discrete Cosine Transformation Implementation in C++

This is a follow-up question for Parallel 3D Discrete Cosine Transformation Implementation in Matlab and Operator overloading in Image class implementation in C++. I am trying to implement 3D Discrete ...
user avatar
  • 3,302
1 vote
1 answer
62 views

next/prev function for a circular array

This is a next/prev function for use in a circular array. What do you think? ...
user avatar
  • 1,354
2 votes
1 answer
110 views

Operator overloading in Image class implementation in C++

This is a follow-up question for Dictionary based non-local mean implementation in C++. There are some issues about operators (operator+ and ...
user avatar
  • 3,302
4 votes
2 answers
333 views

c++20 compile time string utility

While upgrading some meta-program running in production for years to the latest (c++20) standard, I rewrote this particular compile time string utility. Even though this new version produces desired ...
user avatar
  • 65
7 votes
5 answers
917 views

Checking whether a string is a permutation of a palindrome in C++20 - follow-up

This post is the follow-up of Checking whether a string is a permutation of a palindrome in C++20. So, what's new? Well, nothing else except that the procedure is now generic and accepts all ...
user avatar
  • 25.3k
3 votes
1 answer
105 views

Dictionary based non-local mean implementation in C++

This is a follow-up question for Manhattan distance calculation between two images in C++ and Dictionary based non-local mean implementation in Matlab. For learning C++20 and researching purposes, I ...
user avatar
  • 3,302
2 votes
0 answers
150 views

2d Grid - Iterating by Rows / Cells - Take #3

Edited with a bit more unit tests. Preface Following my second version: 2d Grid - Iterating by Rows / Cells - Take #2 I believe that I am now satisfied with this new version below. There is still one ...
user avatar
10 votes
4 answers
1k views

Checking whether a string is a permutation of a palindrome in C++20

(See the next iteration/follow-up here.) I have this short function is_permutation_palindrome, which returns true only if the ...
user avatar
  • 25.3k
7 votes
3 answers
861 views

Checking for NaN bit patterns in C++

I live in hostile environments (GCC and Clang) which remove calls to isnan which prevents me to perform validation of my input before running computations. Here is ...
user avatar
3 votes
2 answers
153 views

Manhattan distance calculation between two images in C++

This is a follow-up question for Two dimensional gaussian image generator in C++ and Image pixelwise operation function with multiple inputs in C++. For learning C++20 and researching purposes, I am ...
user avatar
  • 3,302
3 votes
0 answers
144 views

Implementation of Dynamic Array with allocators and C++20

To train my skills in C++, I decided to implement the well-known "Dynamic array" data structure on my own. I realized early on that using pointers or smart pointers is wrong, as it leads to ...
user avatar
  • 131
2 votes
2 answers
110 views

2d Grid - Iterating by Rows / Cells - Take #2

Preface Following my first POC version: 2d Grid - Iterating by Rows / Cells I have gained much more understanding, and present A new version A new version is ready, with templates and an attempt at ...
user avatar
3 votes
0 answers
73 views

Order guaranteed recursive_transform template function implementation with execution policy in C++

This is a follow-up question for A recursive_transform Template Function with Execution Policy, A recursive_transform Template Function Implementation with std::invocable Concept and Execution Policy ...
user avatar
  • 3,302