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
2
votes
0answers
36 views

Two dimensional bicubic interpolation implementation in C++

This is a follow-up question for Two dimensional bicubic interpolation implementation in C and A recursive_transform Template Function with Unwrap Level for Various Type Arbitrary Nested Iterable ...
5
votes
2answers
976 views

C++20 Coroutine Generator

Here is a coroutine generator class... Just like Python yields. It was a bit tedious to support both co_yield and co_return (...
8
votes
4answers
1k views

std::list reimplementation

I've decided to rewrite the standard library list in a smaller version. This is similar to another question of mine, where my main concern is memory management. I allocate a new array each time the ...
18
votes
3answers
2k views

C++ lock-free, MPMC Ring buffer in C++20

I have some performance critical inter-thread messaging code in C++. Multiple producers, one or more consumers. Profiling dozens of iterations of this messaging code over several years of development, ...
2
votes
3answers
78 views

A file system watcher class for on-fly file reloading when it has been modified

I wrote a file sytem watcher class that is used to monitor file modification and then execute user-defined handler. Other file system events like moving or deleting don't need to be monitored. The ...
4
votes
2answers
70 views

UTF-8 to UTF-16 using C++20 concepts and ranges

A follow-up for this previous question. I took into account previous reviews, and tried to make a simple API. I had never done anything non-trivial with C++20 concepts and ranges until now, so I am ...
5
votes
4answers
546 views

UTF-8 to UTF-16 (char8_t string to char16_t string)

Below is an implementation of a UTF-8 string to UTF-16 string. Kind of like MultiByteToWideChar on Win32, but it's cross-platform and ...
1
vote
0answers
50 views

C++ exception class for error reporting, compatible with C++98 through C++20 (ver 2)

This question contains revised code from the question What should a C++ error reporting exception class have to be portable across language versions?. I summarize what is different from that code at ...
8
votes
2answers
99 views

What should a C++ error reporting exception class have to be portable across language versions? (ver 1)

Link to revised (ver 2) question This question contains the first version of the code for the task explained below. The revised version is at C++ exception class for error reporting, compatible with ...
3
votes
3answers
65 views

Trying for an efficient and readable merge-sort implementation

My first implementation of merge sort in C++. I'm looking for any sort of optimization and/or conventional practice tips, such as using the appropriate data types and naming my variables appropriately....
1
vote
1answer
44 views

(FOLLOW-UP) Header-only bigint library written in c++20

This question is a follow up of Header only bigint library written in c++20. I've made all (or almost all) the corrections suggested in the answers, plus some minor change here and there and a ...
0
votes
0answers
31 views

C++20 Ndim matrix, computing eigenvalues and eigenvectors

My C++20 N-dimensional matrix project now supports basic linear algebra operations: https://github.com/frozenca/Ndim-Matrix Today I want to get some reviews on computing eigenvalues and eigenvectors. ...
1
vote
0answers
26 views

C++20 : Ndim Matrix, broadcasting, np.dot() and np.matmul()

I've improved my N-dimensional C++20 matrix project (C++20 : N-dimensional minimal Matrix class). Implemented general matrix addition/subtraction, elementwise multiplication/division, dot product, ...
6
votes
2answers
182 views

Header only bigint library written in c++20

I made this over the course of a week and a half, to use it for some Project Euler problems. My goal was to make something relatively efficient that could be used as easily as a builtin type. I also ...
7
votes
2answers
841 views

C++20 : N-dimensional minimal Matrix class

I wrote a N-dim matrix (tensor) class, based on my previous 2D matrix implementation(2D Matrix in C++20 and Strassen's algorithm), accepting many helpful reviews from here. MatrixBase.h ...
9
votes
4answers
2k views

C++20 : Simple Softmax classifier for MNIST dataset

I wrote a simple softmax classifier to classify MNIST digit handwriting data set. Feel free to comment anything! ...
13
votes
1answer
300 views

C++ class to create and evaluate Chebyshev approximations of arbitrary functions

I recently needed to create a function to approximate a complex trigonometric function on an embedded system without a floating point unit and without a fast trigonometric library. So I pulled out my ...
0
votes
1answer
36 views

extents_to_array and array_to_extents functions for Boost.MultiArray in C++

This is a follow-up question for A get_extents helper function for Boost.MultiArray in C++. In order to retrieve, manipulate and calculate size information in each dimension from Boost.MultiArray in ...
5
votes
1answer
64 views

Compile-time Matrix Class

Intended as a small project to test out various C++20 features, as well as learn a little bit more about matrices and their uses, I decided to implement a relatively simple matrix class. After ...
5
votes
2answers
281 views

A C++ Program to Plot An Equation

I am fairly new to C++ and I was wondering if there is anything I can improve in this code(perf, readability)? Thanks. This is the full code: Github Link I will post the parser that creates a rpn ...
3
votes
0answers
41 views

A recursive_transform Template Function with Unwrap Level for Various Type Arbitrary Nested Iterable Implementation in C++

This is a follow-up question for A recursive_transform Template Function Implementation with std::invocable concept in C++ and A recursive_transform Template Function Implementation with ...
0
votes
0answers
32 views

A batch_recursive_count_if Function with Unwrap Level for Various Type Arbitrary Nested Iterable Implementation in C++

This is a follow-up question for A recursive_count_if Function For Various Type Arbitrary Nested Iterable Implementation in C++ and A recursive_count_if Function with Unwrap Level for Various Type ...
1
vote
0answers
67 views

“tuple with named fields” implementation

I'd like to show you a type I made while experimenting with literal, non-type template parameters in C++20. The idea is to provide a type that wraps up tuple-like types (std::tuple, std::pair, even ...
0
votes
0answers
25 views

Boost.MultiArray Based Two Dimensional Array to Markdown Table Converter Implementation in C++

I am attempting to implement a converter which can convert two dimensional array (using Boost.MultiArray library) into markdown table. The experimental implementation ...
6
votes
1answer
105 views

C++20 generic math vector implementation

I wrote a math vector implementation using expression templates to add a little boost to "chain operations" like: ...
3
votes
1answer
79 views

Function to use projections in legacy algorithms [closed]

I love the "projections" introduced by the ranges library, and I would like to use them in algorithms that haven't been rangeyfied yet. I had the idea of using them through a function like ...
2
votes
2answers
144 views

Partial function composability in C++

Similar to Partial Function composability in Haskell, I've attempted to implement partial function composability in C++20 via C++ concepts. More details about the problem(for which my solution is ...
10
votes
3answers
821 views

C++20 Vector2D Template

Pretty simple 2-Dimensional Vector template with operators and two utility functions making use of C++20 concepts. Header-only templates, function inlining and operator overloading, etc. is not ...
4
votes
1answer
123 views

Efficient vector-like polymorphic container which retains type information

This is my attempt of implementing an efficient, cache-friendly, vector for polymorphic objects. From now on I will refer to "virtual functions" as functions which are dependent on an object'...
3
votes
1answer
56 views

Piping operator in c++

I wrote a simple piping operator in c++. I just wanted to make sure that my code was robust, modern c++ code, and made correct use of perfect forwarding. Here's the code: ...
5
votes
1answer
84 views

Binary IO inspired by struct pack

About I'm writing a header-only template library for helping with binary IO. It is inspired by pack-d, which is in turn inspired by Python's struct module. I've only finished the output part and ...
0
votes
0answers
45 views

A recursive_count Function with Unwrap Level for Various Type Arbitrary Nested Iterable Implementation in C++

This is a follow-up question for A recursive_count Function For Various Type Arbitrary Nested Iterable Implementation in C++, A recursive_count_if Function with Unwrap Level for Various Type Arbitrary ...
1
vote
1answer
92 views

c++ multithreaded message broadcaster using callbacks

note: This is an updated design after a previous review round. I have written a class that handles listeners registering callbacks to receive messages. Registered callbacks can be replaced or removed. ...
1
vote
0answers
57 views

A Function Applier for Applying Various Algorithms on Nested Container Things in C++

This is a follow-up question for A recursive_replace_if Template Function Implementation in C++, A recursive_copy_if Template Function Implementation in C++, A recursive_count_if Function with Unwrap ...
0
votes
1answer
85 views

Best practice for factory pattern in c++?

I'm implementing a simple data reader to get image sequences from either a pre-recorded video file (In my case ROS bag file), or a camera device (In my case Intel Realsense). Basically I intend for ...
1
vote
0answers
45 views

A recursive_replace_copy_if Template Function Implementation in C++

This is a follow-up question for A recursive_copy_if Template Function Implementation in C++. Besides the recursive version std::ranges::copy_if, I am trying to ...
2
votes
1answer
433 views

C++ callback multithreaded, can unregister itself

update: a new version of this code is posted here With this post, i would like to 1) ask for feedback on below code as it stands: do i apply all best practices for c++20? is it safe? is my way to ...
2
votes
1answer
49 views

A recursive_copy_if Template Function Implementation in C++

This is a follow-up question for A recursive_transform for std::vector with various return type and A recursive_transform Template Function Implementation with std::invocable concept in C++. Besides ...
5
votes
1answer
38 views

Filter out comments in Delphi source code

Today I am working on refactoring and documenting some ancient Delphi code. In that language, which is derived from Pascal, there are three forms of comments: ...
1
vote
1answer
64 views

A recursive_transform Template Function Implementation with recursive_invoke_result_t and std::ranges::transform in C++

This is a follow-up question for A recursive_transform Template Function Implementation with std::invocable concept in C++, A recursive_transform Template Function Implementation with std::invocable ...
0
votes
0answers
68 views

Various Type Test Cases for recursive_transform Template Function in C++

This is a follow-up question for Nested std::deque and std::vector Type Test Cases for recursive_transform Template Function in C++, A recursive_transform Template Function Implementation with ...
3
votes
1answer
79 views

C++20 “FixedArray” Container (dynamically allocated fixed-size array)

I've wrote a FixedArray to fit seamlessly (function-wise) with the default C++ containers, including working with algorithms/etc. It is a dynamically allocated, but fixed size array. Code ...
5
votes
1answer
161 views

2D Matrix in C++20 and Strassen's algorithm

I wrote C++20 implementation of a simple matrix class and its usage in Strassen's \$O(n^{lg_2{7}})\$ matrix multiplication algorithm. Live demo: https://wandbox.org/permlink/JaSC8fQccFbcl1QY (For n = ...
5
votes
1answer
132 views

Generic Visitor pattern library for polymorphic virtual class hierarchies

Inspired by this cppcon talk from Fedor Pikus about design patterns and some real-world need I implemented a library that allows the user to add a generic visitor pattern capabilities to class ...
3
votes
2answers
114 views

Nested std::deque and std::vector Type Test Cases for recursive_transform Template Function in C++

This is a follow-up question for A recursive_transform Template Function Implementation with std::invocable concept in C++, A recursive_transform Template Function ...
5
votes
2answers
87 views

sum of multiples by 3 or 5 using ranges

This program calculates the sum of all integers in the range \$[1, 1000)\$ which are multiples of either 3 or 5 or both. Inspired by x86-64 Assembly - Sum of multiples of 3 or 5 the other day, and ...
4
votes
3answers
367 views

Calculate the centroid of a collection of complex numbers

In working on another problem, one component I needed was to calculate the centroid of a collection of complex objects. The well-known way to calculate this is to simply average the real and ...
2
votes
1answer
67 views

A recursive_transform Template Function Implementation with std::invocable Concept and Execution Policy in C++

This is a follow-up question for A recursive_transform Template Function Implementation with std::invocable concept in C++ and A recursive_transform Template ...
2
votes
1answer
100 views

A recursive_transform Template Function Implementation with std::invocable concept in C++

This is a follow-up question for A recursive_transform for std::vector with various return type, A recursive_transform Template Function with Execution Policy, A recursive_count_if Template Function ...
2
votes
1answer
62 views

A recursive_count_if Template Function with Execution Policy in C++

This is a follow-up question for Avoiding requires clause if possible on a series recursive function in C++ and A recursive_count_if Function with Automatic Type Deducing from Lambda for Various Type ...