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
5
votes
2answers
366 views

C++ custom exception class

I am wondering, how can I improve this simple MissingResource exception class? I am using it in my simple game. ...
2
votes
1answer
81 views

C++20 sort of infinite “Consumer-Producer”

I think I can summarize the idea to the Producer-Consumer problem, with some modifications. And I think i misused the term "Producer" (it depends from which point of view :)) An infinite ...
3
votes
0answers
34 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 ...
1
vote
1answer
56 views

Is there a better solution to get RTTI info about a polymorphic type?

I made some code to get RTTI information of a polymorphic object, it works both if you pass it directly or a pointer to it(the pointer will get dereferenced until null or the object is found), it's ...
2
votes
1answer
35 views

Simple pair/vector2 utility class for c++20

I have rewritten the Vector2 class that I usually use in my projects. The code looks as follows: ...
3
votes
1answer
66 views

Linear Interpolation for sorted arrays

I have made a linear interpolation functions as a side project of mine. It assumes everything is sorted before hand - x and f(x) are the same length. I would like to ask for: general recommendations ...
3
votes
1answer
64 views

Flatten 2d-array at compiletime

In my code, I need to flatten a two-dimensional std::array into a one-dimensional one at compile time. While writing the code I realized, that I am unsure about ...
22
votes
6answers
4k views

Implementing any_of in C++

I've decided to implement Python's any in C++. I've gone about this using templates to allow multiple types of data to be passed, instead of overloading the ...
15
votes
3answers
3k views

2D Collision Detection in C++

I'm attempting to rewrite the classic snake game in c++. What I am inquiring about is my implementation for a 2D collision detection function. I am utilizing ...
2
votes
1answer
37 views

Chunking strings to binary block-based output

This is a follow up to Chunking strings to binary output I found the reviews quite helpful in pinpointing what to fix with my code. Here's the result of that update. The format of the output is the ...
5
votes
2answers
115 views

Chunking strings to binary output

A follow-up to this question is Chunking strings to binary block-based output I have code which takes a text file as input and creates a special binary output form of the input. Specifically, the ...
4
votes
1answer
111 views

Snowflakes in C++

I've started learning C++ using Microsoft Visual Studio. I'm decided to create a simple GUI program that creates a "snowflake" wherever the user clicks on the screen. Seeing as how this is my first C++...
6
votes
2answers
276 views

Playing with operator<=> (operator spaceship) in c++

I have been trying to get a better handle on the operator<=>, so I wrote two different string wrappers. The Strong_String wrapper uses ...
6
votes
1answer
384 views

Max function with variable number of arguments

I find it irritating that in standard C++ I can't do std::max(a, b) = x when it's possible and that it can't handle more than 2 arguments. For the second concern I ...
10
votes
3answers
296 views

C++20 standard compatible vector

I decided to write my own vector class template for learning purposes. My main goal was a correct interpretation of C++20 standard (as of n4810). I took some liberties and decided to use concepts ...
10
votes
1answer
886 views

C++17 <span> implementation

C++20 added the span library under the header <span>. As voluntary exercise (not homework!), I spent approximately 1.5 ...
7
votes
2answers
363 views

Generic way to remove all duplicates from a not-sorted container

Here's an interesting article called "How to Remove Elements from a Sequence Container in C++". At some point, the author also explains how to remove duplicates from a container, but only with the ...
2
votes
1answer
490 views

C++ multithread pool class

I have addressed the critique for this post and resubmitted it for iterative review; C++20 multithread pool class. This is an iteration from a prior post; C++ thread pool class. Class for creating ...
7
votes
2answers
241 views

C++2a comparison-based topological sort algorithm

Here's my attempt at a C++2a Standard Library–friendly "topological sort" algorithm. There are several areas of interest here: The algorithm is comparison-based and in-place, just like ...
6
votes
1answer
870 views

Constexpr unit tests and asserts

I'm trying out some different programming styles to experiment with the new C++ concepts. Within the experiment I was looking into how constexpr could be helpful ...