Questions tagged [c++17]
Code that is written to the 2017 version of the C++ standard. Use in conjunction with the 'c++' tag.
584 questions
5votes
2answers
169views
Design By Contract Library in C++
I asked this question on StackOverflow, and got exactly the answer I needed at the time. I am now here to ask - Is this a good design? The motivation for writing up this library: my shop writes ...
7votes
5answers
815views
6votes
2answers
187views
Markov sentence generator on input file
This is a Markov chain generator. It reads a file, reads all triples of words, and creates the Markov model. The model it makes is weighted, by which I mean that if "word1 word2 word3" ...
9votes
1answer
617views
Arena/Region allocator in C++
Update: 2nd revision on separate post: Arena/Region Allocator in C++ (rev 2) Original Post Trying to get a better grasp on low-level memory management, I implemented an arena allocator in C++. It's a ...
7votes
3answers
586views
Initialize std::map
I would like to make the initialization code for the C++ std::map instance (table in the example below) a little more clean. ...
7votes
3answers
1kviews
C++ code reading from a text file, storing value in int, and outputting properly rounded float
Late important updates (unified) I found, that on my Pi's Debian 12 Bookworm (arm64), there is just an older g++-12 available. ...
4votes
2answers
959views
LeetCode 3366: Minimum Array Sum - w/o DP/memoisation
This program tried to solve LeetCode problem 3366: Minimum Array Sum. It fails for k odd, op1+op2 high enough such there are more odd value to optionally subtract k from than subtractions to allot. A ...
10votes
2answers
2kviews
Robust error handling mechanism in C++ (safer than std::expected)
I've been looking into and experimenting with various paradigms for error handling in C++. My goals for a robust error handling mechanism would be: Enforce handling the error cases (in other words, ...
6votes
1answer
121views
Using `std::variant` to multiplex input methods
I have known about std::variant for a while but had dismissed it as not very useful (I have revised that opinion now). But I would like a second opinion on my usage ...
1vote
1answer
122views
Number of Islands, C++17, Visual Studio [closed]
I have written a program in C++ to answer the problem of the number of islands. I receive (a path to) a text file that consists of an array where . is water, and ...
4votes
1answer
86views
Result class to get either value or error
Recently, I had written a Result class. Basically I wanted a function to return result value on success and some error code on failure. ...
3votes
1answer
87views
C++17 static inline member variables to populate factory at static initialization time
The Context I have a toy ECS architecture where I want to serialize and deserialize the whole app state for hot-reloading DLLs. I don't want the user to have to register all components at the ...
6votes
1answer
217views
Implementing a python range like function in C++17
I came up with a C++17 (I cannot use C++ >= 20 in my project) implementation of a python-like range function (class). The Code "range.hpp" ...
3votes
1answer
72views
Implementation of an Ordered Character Class #2
Overview This is a follow-up review request incorporating commented from the following prior review: Implementation of an Ordered Character Class. I have incorporated many of the suggestions made by ...
2votes
2answers
92views
Implementation of an Ordered Character Class
Overview The code below is my attempt a solving a problem that came up in one of my projects. I needed a type that could be constrained to a defined list of characters, be set to a specific character, ...