Skip to main content

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
7 votes
1 answer
428 views

A recursive_transform for std::vector with various return type

This is the follow-up question for A recursive_transform Function For Various Type Nested Iterable With std::variant Implementation in C++ and A get_from_variant function in C++. Thanks to G. Sliepen ...
JimmyHu's user avatar
  • 5,214
2 votes
1 answer
168 views

A recursive_count_if Function 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++. Thanks to G. Sliepen's answer. Based on the mentioned suggestion, the ...
JimmyHu's user avatar
  • 5,214
5 votes
1 answer
216 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 ...
JimmyHu's user avatar
  • 5,214
3 votes
2 answers
264 views

A recursive_transform Template Function with Unwrap Level for std::array Implementation in C++

This is a follow-up question for A recursive_transform Template Function with Unwrap Level for Various Type Arbitrary Nested Iterable Implementation in C++. I am following the suggestions proposed by ...
JimmyHu's user avatar
  • 5,214
3 votes
0 answers
148 views

A recursive_print Function For Various Type Arbitrary Nested Iterable Implementation in C++

This is a follow-up question for A recursive_transform for std::vector with various return type and A recursive_transform for std::array with various return type. Based on these discussion about the ...
JimmyHu's user avatar
  • 5,214
5 votes
1 answer
111 views

A recursive_count Function For Various Type Arbitrary Nested Iterable Implementation in C++

This is a follow-up question for A Summation Function For Arbitrary Nested Vector Implementation In C++ and A Summation Function For Various Type Arbitrary Nested Iterable Implementation in C++. ...
JimmyHu's user avatar
  • 5,214
3 votes
0 answers
66 views

A recursive_count_if Function with Specified value_type 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++. Thanks to Quuxplusone's answer and G. Sliepen's comments. Based on the ...
JimmyHu's user avatar
  • 5,214
3 votes
1 answer
241 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 ...
JimmyHu's user avatar
  • 5,214
3 votes
1 answer
72 views

A 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++, A recursive_count_if Function with Specified value_type for Various ...
JimmyHu's user avatar
  • 5,214
3 votes
1 answer
94 views

A recursive_count_if Function with Automatic Type Deducing from Lambda 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 Specified value_type for Various ...
JimmyHu's user avatar
  • 5,214
2 votes
1 answer
167 views

A recursive_transform Template Function with Execution Policy

This is a follow-up question for A recursive_transform for std::vector with various return type, A recursive_transform Function For Various Type Nested Iterable With std::variant Implementation in C++ ...
JimmyHu's user avatar
  • 5,214
3 votes
1 answer
220 views

A recursive_transform Function For Various Type Nested Iterable With std::variant Implementation in C++

This is a follow-up question for A TransformAll Function For Various Type Arbitrary Nested Iterable Implementation in C++. The following code is the improved version based on G. Sliepen's answer. In ...
JimmyHu's user avatar
  • 5,214
3 votes
1 answer
237 views

std::array and std::vector Type Arbitrary Nested Iterable Generator Functions Implementation in C++

This is a follow-up question for the previous questions about recursive functions, including A Summation Function For Arbitrary Nested Vector Implementation In C++, A recursive_count_if Function For ...
JimmyHu's user avatar
  • 5,214
2 votes
1 answer
101 views

An arithmetic_mean Function 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++ and A Summation Function For Boost.MultiArray in C++. I am trying to ...
JimmyHu's user avatar
  • 5,214
2 votes
1 answer
110 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 ...
JimmyHu's user avatar
  • 5,214
1 vote
1 answer
185 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 ...
Diederick C. Niehorster's user avatar
11 votes
1 answer
2k views

C++ : B-Tree in C++20 (+Iterator support)

I wrote a B-Tree implementation in C++20, based on my previous Red-Black Tree implementation. Unit Test Demo : https://wandbox.org/permlink/Brw6TgAhdy89OIyj Any feedback will be welcomed! ...
frozenca's user avatar
  • 1,703
5 votes
1 answer
142 views

Multithreaded console-based monster battle with earliest-deadline-first scheduler

In working on this answer it occurred to me that it might be interesting to further expand the idea. The game This is an extremely simple (and boring!) text-based game that creates a few monsters ...
Edward's user avatar
  • 66.5k
3 votes
1 answer
143 views

An element_wise_add Function For Boost.MultiArray in C++

This is a follow-up question for A Summation Function For Boost.MultiArray in C++. Besides the summation operation of all elements, I am trying to focus on the element-wise operation here. The main ...
JimmyHu's user avatar
  • 5,214
3 votes
1 answer
96 views

A recursive_transform for std::array with various return type

This is a follow-up question for A recursive_transform for std::vector with various return type. Thanks to G. Sliepen provide further review suggestions. After digging into the topic of achieving a ...
JimmyHu's user avatar
  • 5,214
3 votes
0 answers
57 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 ...
Diederick C. Niehorster's user avatar
2 votes
1 answer
136 views

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

This is a follow-up question for A Summation Function For Various Type Arbitrary Nested Iterable Implementation in C++ and A recursive_transform_view Template Function Implementation. In the previous ...
JimmyHu's user avatar
  • 5,214
12 votes
5 answers
2k views

Portable Object-Oriented WC (Linux Utility word Count) C++ 20, Counts Lines, Words Bytes

This question Code lines counter prompted me to write my own line counting program. I program on both Windows and Linux and I know about the Linux utility wc. The command line and output format are ...
pacmaninbw's user avatar
  • 24k
8 votes
2 answers
446 views

Two dimensional gaussian image generator in C++

This is a follow-up question for Two dimensional bicubic interpolation implementation in C++ and Two dimensional gaussian image generator in C. Based on user673679's answer, another file ...
JimmyHu's user avatar
  • 5,214
7 votes
2 answers
2k 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 ...
frozenca's user avatar
  • 1,703
6 votes
1 answer
184 views

A Various Container Type Arbitrary Nested Iterable Generator Function Implementation in C++

This is a follow-up question for std::array and std::vector Type Arbitrary Nested Iterable Generator Functions Implementation in C++ and std::deque and std::list Type Arbitrary Nested Iterable ...
JimmyHu's user avatar
  • 5,214
6 votes
1 answer
152 views

Non-nested std::deque and std::list Generator Function for arithmetic_mean Function Testing in C++

This is a follow-up question for A non-nested test_vectors_generator Function for arithmetic_mean Function Testing in C++ and An arithmetic_mean Function For Various Type Arbitrary Nested Iterable ...
JimmyHu's user avatar
  • 5,214
5 votes
2 answers
4k views

C++20 Thread Pool

I've implemented a thread pool using C++20. I'm fairly new to concurrently/multi-threaded programming and wanted to work on a project that I could learn from while also getting to know some of the new ...
Developer Paul's user avatar
4 votes
2 answers
2k views

Fast OrderBook Implementation

I'm creating a simple yet fast OrderBook, that only adds orders and matches them (no cancelling or modifications, etc.). I'm using partial template specialization to reduce branching in the hotpath, ...
jpf's user avatar
  • 63
4 votes
1 answer
78 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
4 votes
1 answer
146 views

An Add/Minus Operator For Boost.MultiArray in C++

This is a follow-up question for An element_wise_add Function For Boost.MultiArray in C++. The following code is the improved version based on G. Sliepen's answer. On the other hand, the built-in ...
JimmyHu's user avatar
  • 5,214
4 votes
2 answers
141 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 ...
JimmyHu's user avatar
  • 5,214
3 votes
1 answer
127 views

A recursive_foreach_all Template Function Implementation in C++

This is a follow-up question for A recursive_fold_left_all Template Function Implementation in C++. As mentioned in G. Sliepen's answer, I am trying to implement <...
JimmyHu's user avatar
  • 5,214
3 votes
1 answer
110 views

A recursive_transform Template Function for BoostMultiArray

This is a follow-up question for A Sine Template Function For Boost.MultiArray in C++, A recursive_transform for std::array with various return type, A recursive_transform for std::vector with various ...
JimmyHu's user avatar
  • 5,214
3 votes
1 answer
69 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 ...
Diederick C. Niehorster's user avatar
3 votes
2 answers
165 views

Goats up hills II: revenge of the goat

This is a continuation of Goat racing up a hill (C++ hiring take-home) . This is an interview take-home challenge that has been translated to avoid compromising the company's question. Problem ...
Reinderien's user avatar
  • 62.5k
2 votes
1 answer
106 views

A recursive_transform template function for the binary operation cases in C++

This is a follow-up question for A recursive_transform Template Function with Unwrap Level for Various Type Arbitrary Nested Iterable Implementation in C++ and A recursive_print Function For Various ...
JimmyHu's user avatar
  • 5,214
2 votes
1 answer
116 views

A recursive_depth function for calculating depth of nested types implementation in C++

This is a follow-up question for A recursive_count Function with Unwrap Level for Various Type Arbitrary Nested Iterable Implementation in C++. A function ...
JimmyHu's user avatar
  • 5,214
2 votes
2 answers
200 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 ...
Shigoto Shoujin's user avatar
2 votes
1 answer
148 views

A recursive_reduce_all Template Function Implementation in C++

This is a follow-up question for A recursive_sum Template Function Implementation with Unwrap Level in C++ and A recursive_unwrap_type_t Struct Implementation in C++. Considering the answer provided ...
JimmyHu's user avatar
  • 5,214
2 votes
1 answer
65 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 ...
JimmyHu's user avatar
  • 5,214
1 vote
0 answers
58 views

A non-nested test_vectors_generator Function for arithmetic_mean Function Testing in C++

This is a follow-up question for An arithmetic_mean Function For Various Type Arbitrary Nested Iterable Implementation in C++. As Toby Speight's answer mentioned, some self-checking unit tests are ...
JimmyHu's user avatar
  • 5,214
1 vote
1 answer
125 views

Avoiding requires clause if possible on a series recursive function in C++

This is a follow-up question for A recursive_transform_reduce Function for Various Type Arbitrary Nested Iterable Implementation in C++, A recursive_count Function For Various Type Arbitrary Nested ...
JimmyHu's user avatar
  • 5,214
1 vote
1 answer
93 views

A population_variance Function For Various Type Arbitrary Nested Iterable Implementation in C++

This is a follow-up question for A Summation Function For Various Type Arbitrary Nested Iterable Implementation in C++, An arithmetic_mean Function For Various Type Arbitrary Nested Iterable ...
JimmyHu's user avatar
  • 5,214
22 votes
6 answers
14k 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 ...
Maysara Elshewehy's user avatar
14 votes
1 answer
1k 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 ...
Edward's user avatar
  • 66.5k
12 votes
3 answers
4k views

Goat racing up a hill (C++ hiring take-home)

This is an interview take-home challenge that has been translated to avoid compromising the company's question. Problem statement You are a goat that needs to race up a hill. Designated waypoint rocks ...
Reinderien's user avatar
  • 62.5k
10 votes
8 answers
1k views

Print all correct parenthesis sequences of () and [] of length n in lexicographical order

Given a number n, print all correct parenthesis sequences of parentheses and square brackets of length \$n\$ in lexicographical order. You must enter an integer \$n\$ from 0 to 16 inclusive. The ...
Dmitry's user avatar
  • 317
10 votes
4 answers
2k 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 ...
coderodde's user avatar
  • 28.7k
9 votes
1 answer
540 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 ...
JimmyHu's user avatar
  • 5,214